Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Problem with dialogs...

SephirothSephiroth Fayetteville, NC, USAMember Posts: 1,035
It's been a while since I have had to create dialogs, but I need to for my current project and it is not working correctly. The dialog appears, but it has no title-bar or window behind the buttons, text, and group control. It's like controls just appear on my main (parent) window. Here's the code I am attempting to use.
[code]
//Resource file
IDD_AREAPROP DIALOGEX 0, 0, 320, 240
CAPTION "Area Properties"
FONT 8, "MS Sans Serif"
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
BEGIN
DEFPUSHBUTTON "&OK", IDOK, 174, 18, 50, 14
PUSHBUTTON "&Cancel", IDCANCEL, 174, 35, 50, 14
GROUPBOX "About this program...", 100, 7, 7, 225, 52
CTEXT "Centered text", 101, 16, 18, 144, 33
END

//Main window callback
case IDM_WORLD_PROPERTIES:
if(DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_AREAPROP), hwndWindow, (DLGPROC)AreaPropCalls) == IDOK)
MessageBox(hwndWindow, "Dialog returned OK", "Debug", MB_OK);
else
MessageBox(hwndWindow, "Dialog returned cancel", "Debug", MB_OK);
return 0;
[/code]
So what is wrong here? I return 'true' on the 'WM_INITDIALOG' message on the dialog callback and it appears to work as far as clicking 'OK' or 'Cancel', but something just is NOT right. Ideas?

-[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

Comments

  • way0endway0end Member Posts: 43
    : It's been a while since I have had to create dialogs, but I need to
    : for my current project and it is not working correctly. The dialog
    : appears, but it has no title-bar or window behind the buttons, text,
    : and group control. It's like controls just appear on my main
    : (parent) window. Here's the code I am attempting to use.
    : [code]:
    : //Resource file
    : IDD_AREAPROP DIALOGEX 0, 0, 320, 240
    : CAPTION "Area Properties"
    : FONT 8, "MS Sans Serif"
    : STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
    : BEGIN
    : DEFPUSHBUTTON "&OK", IDOK, 174, 18, 50, 14
    : PUSHBUTTON "&Cancel", IDCANCEL, 174, 35, 50, 14
    : GROUPBOX "About this program...", 100, 7, 7, 225, 52
    : CTEXT "Centered text", 101, 16, 18, 144, 33
    : END
    :
    : //Main window callback
    : case IDM_WORLD_PROPERTIES:
    : if(DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_AREAPROP), hwndWindow, (DLGPROC)AreaPropCalls) == IDOK)
    : MessageBox(hwndWindow, "Dialog returned OK", "Debug", MB_OK);
    : else
    : MessageBox(hwndWindow, "Dialog returned cancel", "Debug", MB_OK);
    : return 0;
    : [/code]:
    : So what is wrong here? I return 'true' on the 'WM_INITDIALOG'
    : message on the dialog callback and it appears to work as far as
    : clicking 'OK' or 'Cancel', but something just is NOT right. Ideas?
    :
    : -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/gre
    : en][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h
    : [/red][/b][/italic]




    I stick without EX;
    *.rc
    ID_DIALOG_NOTES DIALOG DISCARDABLE 0,0,293,383
    STYLE WS_POPUP|WS_CAPTION|DS_MODALFRAME|WS_SYSMENU
    CAPTION "Mark Notes"
    FONT 8, "MS Sans Serif"
    {
    GROUPBOX "Send / Receive",IDC_STATIC,7,7,130,70
    }


    MAIN,
    switch(msg)
    {
    case WM_COMMAND:
    switch(wp)
    {
    case ID_BN_WNDPROC_MAIN_NOTES:
    DialogBox((HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE), MAKEINTRESOURCE(ID_DIALOG_NOTES), hwnd,Notes );
    break;
  • SephirothSephiroth Fayetteville, NC, USAMember Posts: 1,035
    I have tried it with the older and, according to MS, deprecated "DIALOGBOX" identifier, but the same problem arises. The callback is declared as "bool CALLBACK FuncName(HWND, UINT, WPARAM, LPARAM)", should I change it to DLGPROC from CALLBACK or would that bother it at all? Here is the current code, and all it does is make the two buttons appear and disable access to the main window. The dialog is invisible aside from the two buttons.
    [code]
    IDD_AREAPROP DIALOGEX 0, 0, 320, 240
    CAPTION "Area Properties"
    FONT 8, "MS Sans Serif"
    STYLE WS_POPUP | WS_BORDER
    {
    DEFPUSHBUTTON "&OK", IDOK, 174, 18, 50, 14
    PUSHBUTTON "&Cancel", IDCANCEL, 174, 35, 50, 14
    }
    [/code]
    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]
  • way0endway0end Member Posts: 43
    here is a sample hope it will help,
    nice day....

    BOOL _stdcall Notes(HWND hwndNotes, UINT msg, WPARAM wp, LPARAM lp)
    {
    switch(msg)
    {
    case WM_INITDIALOG:
    return 1;
    case WM_COMMAND:switch(LOWORD(wp))
    {
    case IDCANCEL:
    EndDialog(hwndNotes, 0);
    return 1;
    }
    return 0;
    }
    return 0;
    }
  • SephirothSephiroth Fayetteville, NC, USAMember Posts: 1,035
    That's exactly what I have. This is something else, and I am starting to think that is is a Visual Studio 2005 issue. The reason I believe it is an IDE issue is because I am now creating a combobox on the main window and while it accepts and works with keyboard input, when you click on the drop-down list with the mouse, nothing happens. All selections have to be made from the keyboard. There is nothing special about the box either, as it is created with 'CreateWindowEx()' and contains only the styles 'WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST'.
    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]
Sign In or Register to comment.