Dialog Boxes

Hello Experts...

At first... NOT USING MFC.
Well, I'm trying to learn something about Dialog Boxes...

I created a Dialog Box...
It has 1 Edit, and two buttons.
Style Overlapped, Visible.
Well

Just trying to show it as modal less, I use something like this:



hDlgTest = CreateDialog(hInst, (LPCTSTR)IDD_DLGTEST,hWnd,(DLGPROC)DlgTest);

All the parameters seem to be fine, the resourse Id, the owner, and the Proc.
It shows the dialog as owner's child.
Whats could be wrong?.

Seccond... I try to get the text of the Edit.

LRESULT CALLBACK DlgTest(HWND hTest, UINT message, WPARAM wParam, LPARAM lParam)

{

LPTSTR Texto;

switch (message)

{
            case WM_INITDIALOG:
                  return TRUE;
      case WM_COMMAND:
      switch (wParam)
            {
            case IDOK: //Button
            DestroyWindow (hTest);
            break;
            case IDC_TEXT: //button2
                GetDlgItemText(hTest,(int)TTEXT, Texto, 50);
            break;
            }
}

}

Well... The seccond button = GPF...
Hwo can help me?.

I would appresiate an example of code for a modal less dialog, with an edit and a button that gets the text in the edit.

Well... It seems to be easier to create a dialog with createWindow than doing it by designing it with the resourse editor :-)

Thanks.

I'm sorry for the points, but when you learn this language... you save points :-)

LVL 1
MarscAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
ZoppoConnect With a Mentor Commented:
Hi Marsc,

you have to allocate a memory for Texto, i.e.:

char Texto[50];

or

LPCTSTR Texto= new char [50];
GetDlgItem( hTest, (int)TTEXT, Texto, 50 );
// do anything with the Texto
delete[] Texto;

hope that helps,

ZOPPO
0
 
MarscAuthor Commented:
Hi...

Well... thanks...
0
All Courses

From novice to tech pro — start learning today.