little WinAPI problem

Started by
8 comments, last by Hassanbasil 14 years, 1 month ago
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 ) )
Advertisement
er.. Maybe I misunderstand something, but that's the intent of a dialog box. You are forced to deal with it.
Modal dialog ?
A Dialog is always modal (I hope I'm right, if not, then shoot me).
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.
*bang*

:) Hahaha...Ahem.
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 );}
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.

"I can't believe I'm defending logic to a turing machine." - Kent Woolworth [Other Space]

Quote:Original post by Hassanbasil
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
*** 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."
Quote:Original post by jwezorek
Quote:Original post by Hassanbasil
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
*** 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!

This topic is closed to new replies.

Advertisement