• 13
• 18
• 19
• 27
• 10

# little WinAPI problem

This topic is 2925 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, everyone! I'm trying to make a dialog box ( using a resource ) with CreateDialogA, i got it working properly except one little problem, my main ( parent ) window is not responding for "X" (close button), windows is not sending a message when X is clicked, i also cant access the menu bar, its "disabled", why is that? ( note that all these effects disappear when i destroy the dialog ( or don't create it at all ) )

##### Share on other sites
er.. Maybe I misunderstand something, but that's the intent of a dialog box. You are forced to deal with it.

Modal dialog ?

##### Share on other sites
A Dialog is always modal (I hope I'm right, if not, then shoot me).

##### Share on other sites
You're probably using the API call DialogBox(), right? DialogBox() box creates a modal dialog which means it disables its owner window.

If you don't want a modal, use CreateDialog() instead of DialogBox().

If you do want a modal but not quite as locked down as the modal state created by DialogBox(), you can implement a DoModalDialog() function yourself by calling CreateDialog() and then going into a message loop inside of your DoModalDialog() function.

##### Share on other sites
*bang*

:) Hahaha...Ahem.

##### Share on other sites
Hello, sorry for the late reply,

i'm making the dialog with CreateDialog, actually, it locks parent, but not other childs, all i want is a dialog that acts as a toolbar, like, it can be used without locking any other windows

EDIT: some code
//.rc fileID_DLG_FUNC DIALOGEX 0, 0, 194, 314STYLE WS_POPUPFONT 8, "MS Shell Dlg", 400, 0, 0x1BEGIN	GROUPBOX		"Function", ID_FUNCGRP, 5, 5, 180, 60	EDITTEXT		ID_FUNCTXT, 15, 20, 160, 15	DEFPUSHBUTTON	"Insert Function", ID_INSERTFUNC, 15, 40, 160, 15END//.cppfuncWnd = CreateDialogA( NULL, MAKEINTRESOURCEA ( ID_DLG_FUNC ), ParentWnd, (DLGPROC)FuncProc );	if ( !funcWnd )	{		MessageBoxA ( NULL, "Unable to create function window", _APPNAME_, MB_OK );		exit ( 0 );	}//...//...LRESULT CALLBACK FuncProc ( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ){	return DefWindowProcA ( hWnd, message, wParam, lParam );}

##### Share on other sites
If you want to make a window like a toolbar, then you can create a seperate window useing CreateWindowEx and using WS_EX_TOOLWINDOW as the dwExstyle parameter. You will probably need to register a new window class and possibly have a seperate window procedure for it.

##### Share on other sites
Quote:
 Original post by HassanbasilHello, sorry for the late reply,i'm making the dialog with CreateDialog, actually, it locks parent, but not other childs, all i want is a dialog that acts as a toolbar, like, it can be used without locking any other windowsEDIT: some code*** Source Snippet Removed ***

I think that you shouldn't be calling DefWindowProc from a dialog box procedure. In FuncProc(), try just returning FALSE instead, which I think tells windows, "I'm not handling this message, so do default handling of it."

##### Share on other sites
Quote:
Original post by jwezorek
Quote:
 Original post by HassanbasilHello, sorry for the late reply,i'm making the dialog with CreateDialog, actually, it locks parent, but not other childs, all i want is a dialog that acts as a toolbar, like, it can be used without locking any other windowsEDIT: some code*** Source Snippet Removed ***

I think that you shouldn't be calling DefWindowProc from a dialog box procedure. In FuncProc(), try just returning FALSE instead, which I think tells windows, "I'm not handling this message, so do default handling of it."

that is exactly what i was looking for, thanks man!