-
June 11th, 2010, 12:01 AM
#1
Winapi, dialog box procedure problem
Hey , first post Thanks all in advance, ive already been helped soo much by this site and others.
Problem: I have 2 dialog box's and 2 dialog box procedures: BOOL 'name'DlgProc(bla bla).
I am using a resource file to define the buttons, sizes ect.
My 2 dialog box's work perfectly,I run into a issue when i create the third.
Create Box definitions in resource file much the same as the others, create a third DlgProc().
I run the program, when I open the first 2 dialog box's that work perfectly.
When i run the third however, the box itself doesnt quite draw or become its own entity so
to speak.
I can see/click/edit the buttons/editbox's but the box itself doesnt draw.
Now the percuilar(i cant spell) thing is that if, when i call the third dialog box, i instead of calling
the new(third) DlgProc(), i call the second or the first, it draws perfectly.
I have cut and pasted the first and second dialog box procedures and simply renamed and still
the same issue(so i know its not some coding error, thus i didnt post any).
Happy to post code if nessasry, but as i said, i have 2 box's working perfectly if i get rid of one of the other box's proc,
the third works, is there a limit on how many DlgProc()'s your aloud to have?
Thanks in Advance, Michael.
-
June 11th, 2010, 07:29 AM
#2
Re: Winapi, dialog box procedure problem
Best to post some code. Even better, assuming you're using Visual Studio, zip up your project directory (minus the .ncb, .aps, .suo, files and Debug and Release directories) ans post it here. There's no way to diagnose your problem from the information given.
-
June 12th, 2010, 12:16 AM
#3
Re: Winapi, dialog box procedure problem
Code:
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
// globals
char szClassName[ ] = "Mb Program !";
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{//WinMain() Open
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MYICON));
wincl.hIconSm = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MYICON), IMAGE_ICON, 16, 16, 0);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = MAKEINTRESOURCE(IDR_MYMENU); /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default color as the background of the window */
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;
/* create the program window*/
hwnd = CreateWindowEx (
WS_EX_DLGMODALFRAME, /*Specifies the extended window style of the window being created*/
szClassName, /* Classname */
"MB TIPPIN", /* Title Text */
WS_OVERLAPPEDWINDOW, /* style - default window */
200, /* X pos */
200, /* Y pos */
544, /* The programs width */
375, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
/* Make the window visible on the screen */
ShowWindow (hwnd, nFunsterStil);
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{ //While Open
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}//While Close
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}// WinMain() Close
Code:
// first dlgproc
BOOL CALLBACK ENTERTIPSDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{//open TipsDlgProc
switch(Message)
{//open Switch
case WM_INITDIALOG:
{
return TRUE;
}
case WM_COMMAND:
{//wm command open
switch(LOWORD(wParam))
{
//case's
}
}
}
// 2 OTHER DLG PROCS THE SAME AS THIS, EXCEPT DIFFERNT CASES FOR BUTTONS ECT
Code:
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{//WindowProcedure() open
switch (message) /* handle the messages */
{ // Switch Open
case WM_DESTROY:
{
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
}
// ******* START WM_COMMAND ***************************************WM_COMMAND*********
case WM_COMMAND:
{ //WM_COMMAND Open
switch(LOWORD(wParam))
{//Switch(LOWORD(wParam)) open
case ID_FILE_EXIT: // exit check and exit...
if((MessageBox(hwnd, "Are you Sure you want to quit?","Attention",
MB_YESNO | MB_ICONEXCLAMATION) ==IDNO))
return DefWindowProc(hwnd, message, wParam, lParam);
else PostQuitMessage (0);
break;
case ID_FILE_NEW:
{//ID_FILE_NEW open
DialogBox(GetModuleHandle(NULL),
MAKEINTRESOURCE(IDD_NEW), hwnd, NewDlgProc);
break;
} /* ID_FILE_NEW CLOSE */
case ID_FILE_ENTERTIPS:
{ //ID-FILE_ENTERTIPS open
DialogBox(GetModuleHandle(NULL),
MAKEINTRESOURCE(IDD_ENTERTIPS), hwnd, ENTERTIPSDlgProc);
break;
} // ID_FILE_ENTER TIPS CLOSE
case ID_FILE_ENTER_RESULTS:
{
DialogBox(GetModuleHandle(NULL),
MAKEINTRESOURCE(IDD_ENTER_RESULTS), hwnd, ENTERTIPSDlgProc);
break;
}
}/* WM_command Switch Bracket Close */
} /* Wm_command Bracket Close*/
default: /* Default for WindowProcedure() Switch */
return DefWindowProc (hwnd, message, wParam, lParam);
} /* WindowProcedure() Switch(message) bracket Close*/
//************************************************************
Working with Dev C++ compiler.
Sorry if posting code like this is wrong, first time ive posted on this site(any site acually )/
Last edited by ovidiucucu; June 12th, 2010 at 09:42 AM.
Reason: aded [CODE] and [/CODE] tags
-
June 12th, 2010, 12:18 AM
#4
Re: Winapi, dialog box procedure problem
//***********************************************************************************
IDD_NEW DIALOG 0, 0, 239, 66 // ID = IDD_NEW TYPE = Dialog box
CAPTION "New Player Rego" // diaglog box name
FONT 12, "MS Sans Sherri" //font and text type
BEGIN
CTEXT "Player Name:", IDC_STATIC, 10,29,90,14 // text in dialog box
EDITTEXT IDC_EDITBOX, 80,24,90,14, ES_AUTOHSCROLL // edit box for dialog box
DEFPUSHBUTTON "Create Player", ID_CREATE_PLAYER,174,24,50,14 // create button for dialog box
PUSHBUTTON "Quit", ID_QUIT, 174,45,50,14 // quit button for dialog box
END
//**************************************************************************
All three dialog box's have exact same structure as this.
and everythign is defined in header file correctly
-
June 13th, 2010, 02:02 AM
#5
Re: Winapi, dialog box procedure problem
Originally Posted by eggyegg123
Code:
MAKEINTRESOURCE(IDD_ENTERTIPS), hwnd, ENTERTIPSDlgProc);
........
MAKEINTRESOURCE(IDD_ENTER_RESULTS), hwnd, ENTERTIPSDlgProc);
So, you are using the same dialog proc routine for two different dialog windows? I wonder if this is part of the problem.
-
June 13th, 2010, 06:17 AM
#6
Re: Winapi, dialog box procedure problem
srry bout the bodgey code dump, will try post more compilable code tomoz( main project is on work pc, i work alotta night shifts and get time to code in the wee hours of the morning).
Quote: cosmicvoid
*So, you are using the same dialog proc routine for two different dialog windows? I wonder if this is part of the problem.
Well yes atm i am its a bad solution to the problem im having, if i call one of the first 2 procedures for the third dialog box, the box functions as expected. Its only when i call the third procedure that the box will not draw correctly, even if i simply copy/paste the first/second procedure and rename it.
Atm im using the second dialog procedure to open my third dialog box, and using unique case ID's to give it functionality, its working quite well, but i know its wrong and don't understand why im having the issue to begin with
Thanks for taking the time to look it over any way, i will post full code, zipped or other wise tommorow.
(program should run on your pc, however will not function as intended, due to fixed file paths im using for testing.)
-
June 13th, 2010, 05:32 PM
#7
Re: Winapi, dialog box procedure problem
I can see/click/edit the buttons/editbox's but the box itself doesnt draw.
Usually this happens when dialog procedure returns TRUE by default.
Code:
BOOL CALLBACK DlgProc(HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
{
. . .
return TRUE; // while FALSE should be here
}
Last edited by Igor Vartanov; June 13th, 2010 at 05:35 PM.
Best regards,
Igor
-
June 13th, 2010, 08:48 PM
#8
Re: Winapi, dialog box procedure problem
ahh ok, il try that tonight, and let you know how it goes thx very much for the tip.
-
June 12th, 2010, 10:13 AM
#9
Re: Winapi, dialog box procedure problem
Trying to cut-n-paste all that into something that I can get to compile is proving to be near impossible. Do you have a project you can zip up?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|