Re: About HWND of the dialog in the CDiloag based class

From: Joseph M. Newcomer (newcomer_at_flounder.com)
Date: 02/24/04


Date: Mon, 23 Feb 2004 20:37:46 -0500

You might also want to check out my essays on dialog boxes on my MVP Tips site. But it
sounds like you are trying to shoehorn some old Win32 native programming knowledge into
MFC, where the framework handles most of these details for you. For example, the very
existence of the MainDialog function for what I'm guessing to be a dialog-based app
suggests that you have gotten very lost along the way. An MFC-based dialog app would have
a dialog subclass that handled this, and it would have a message map to handle all the
message dispatches. Consequently, most of the questions you are asking become quite
different.
                                joe

On Mon, 23 Feb 2004 18:40:05 -0600, "Jeff Partch" <jeffp@mvps.org> wrote:

>"Jitesh Virani" <jiteshvirani2004@yahoo.co.in> wrote in message
>news:008401c3fa60$35de2060$a301280a@phx.gbl...
>> Hello Jeff Partch,
>>
>> If MainDialog function seems incompatible with
>> MFC, which alternative is available in MFC for this?
>> You have suggested me to use GetDlgCtrlID function
>> but the syntas of this function says:
>> int GetDlgCtrlID(
>> HWND hwndCtl
>> );
>
>Not necessarily incompatible, just oddly prototyped for what it appears to
>be and rather unusual.
>
>> How do I get this HWND of the control?
>
>You can use GetDlgItem, or you can use VC wizards to map the HWND to a
>control member variable. MFC wraps alot of the Win32 API ways of doing
>things in C++ classes and member functions that automatically provide the
>HWND or whatever. For example, CWnd::GetDlgCtrlID does not need the HWND
>parameter, but it needs a CWnd that has been attached to the HWND.
>
>> I want to manipulate the text that is entered at
>> runtime into TextBox with specific property. In the same
>
>This TextBox is an EDIT control? If so, CWnd::SetWindowText and
>CWnd::GetWindowText come immediately to mind. There are also CEdit member
>functions that wrap the EM_xxx messages. There is also CWnd::SetDlgItemText
>and CWnd::GetDlgItemText. I'm not sure how you intend to manipulate the
>text, so I'm not sure which exactly would be best.
>
>> way, I want to make use of the selected text of ComboBox
>> at runtime by the user through one of it's properties. I
>
>You should look at the CListBox member functions and see if any of those
>offer the information you want to set or get.
>
>> am referring to the term property as per the vb
>> convension. It is possible that in VC it may have other
>> nameing convension. As I am new to VC programming that I
>> am somewhat unable to explain my problem to you.
>> I mean to say Is it possible for me to get the
>> HWND of DialogBox, in the class which has the declaration
>> like MyDialog::CDialog.
>
>Yes, in the CDialog derived class you can use the m_hWnd member variable.

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm



Relevant Pages

  • Re: Get Window Handle
    ... Why do you need the HWND? ... you can safely assume that there is an MFC method that corresponds to the ... Win32 API; and furthermore, even though the API appears to be more "modern" (e.g., ... because what m_pMainWnd represents is either a frame window or dialog window ...
    (microsoft.public.vc.mfc)
  • Re: About HWND of the dialog in the CDiloag based class
    ... > MFC, which alternative is available in MFC for this? ... > HWND hwndCtl ... control member variable. ... Jeff Partch ...
    (microsoft.public.vc.mfc)
  • Re: MFC modal dialog box over Visual Basic application
    ... > When I click the VB application while the MFC dialog is displayed, ... > from the dialog box is not lost. ... That doesn't prove the HWND is the right one - the HWND you are passing ... > I tried Spy++ and there are in fact two application level windows. ...
    (microsoft.public.vc.mfc)
  • Re: Basic question regarding checkboxes
    ... It appears that your real problem is not understanding that the above call is to a C++ member function. ... Your error message shows you are not calling the MFC version of CheckDlgButton but attempting to call the API version. ... The MFC version is a member function of the dialog and it "knows" the HWND of the dialog. ... If you are making this call in some code module that is not part of the dialog then first you have to call that module, passing it the 'this' pointer from the dialog object. ...
    (microsoft.public.vc.mfc)
  • Re: How to get list of immediate child directories
    ... MFC code. ... it is WTL. ... Much lighter weight, and usable by ... | MVP Tips: http://www.flounder.com/mvp_tips.htm ...
    (microsoft.public.vc.mfc)

Loading