problem creating two dialogs

hi,
i'm hoping someone can spot the beginner error without me posting all my code. i'd hate to ask anyone to pick through that.

i have created a dialog for my app with the CreateWindowEx function.. you know, like the way photoshop brings up a dialog to adjust brightness and contrast. it's not the main app window.

my problem is i want to create a second dialog box that functions like this, but it brings up all the controls that are on the first dialog, and i can't seem to find a way to discretise it as it's own, seperate dialog.

the 2nd dialog appears in the correct place for the 2nd dialog, but both share the same controls simultaneously.

alright... i'm going to post all my code (ripping out the massive case WM_COMMAND: function, because this app is already sizeable...)

don't laugh because the 2nd dialog has silly madeup names.. at this stage, i've just tried giving *every* variable its own name. as far as i can tell, i've given every variable its own name...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86

/////////////////////////////////////////////////////////////////
////////////////	HEIGHT FIELD DIALOG
/////////////////////////////////////////////////////////////////

LRESULT CALLBACK HFDlgProc( HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam ) {
	hhfdlg = hdlg;
	HDC         hdc;
	PAINTSTRUCT ps;
	HFONT		hfont;

	INITCOMMONCONTROLSEX InitCtrlEx;	//	for progress bar
	InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
	InitCtrlEx.dwICC  = ICC_PROGRESS_CLASS;
	InitCommonControlsEx(&InitCtrlEx);

	switch(msg) {
//////////let's leave this out for now
	}
	return (DefWindowProc(hdlg, msg, wParam, lParam));
}

void RegisterHFDlgClass(HWND hwnd) {
  WNDCLASSEX wc = {0};
  wc.cbSize           = sizeof(WNDCLASSEX);
  wc.lpfnWndProc      = (WNDPROC) HFDlgProc;
  wc.hInstance        = ghInstance;
  wc.hbrBackground    = GetSysColorBrush(COLOR_3DFACE);
  wc.lpszClassName    = TEXT("DialogClass");
  RegisterClassEx(&wc);
}

void CreateHFDlgBox(HWND hwnd) {
  CreateWindowEx(WS_EX_DLGMODALFRAME | WS_EX_TOPMOST,  TEXT("DialogClass"), TEXT("Height Field"),
        WS_VISIBLE | WS_SYSMENU | WS_CAPTION , 0, 21, 192, 285,
        NULL, NULL, ghInstance,  NULL);
}










/////////////////////////////////////////////////////////////////
////////////////	WATER DIALOG
/////////////////////////////////////////////////////////////////

LRESULT CALLBACK WaterDlgProc( HWND hwdlg, UINT msg, WPARAM wParam, LPARAM lParam ) {
	HDC         hdc;
	PAINTSTRUCT ps;
	HFONT		hfont;

	switch(msg) {
//////////// let's leave this out for now....
	}


	return (DefWindowProc(hwdlg, msg, wParam, lParam));
}






void RegisterWaterDlgClass(HWND hwwnd) {
  WNDCLASSEX wwc = {0};
  wwc.cbSize           = sizeof(WNDCLASSEX);
  wwc.lpfnWndProc      = (WNDPROC) WaterDlgProc;
  wwc.hInstance        = whInstance;
  wwc.hbrBackground    = GetSysColorBrush(COLOR_3DFACE);
  wwc.lpszClassName    = TEXT("DialogClass");
  RegisterClassEx(&wwc);
}

void CreateWaterDlgBox(HWND hwwnd) {
  CreateWindowEx(WS_EX_DLGMODALFRAME | WS_EX_TOPMOST,  TEXT("DialogClass"), TEXT("Water"),
        WS_VISIBLE | WS_SYSMENU | WS_CAPTION , 0, 306, 192, 285,
        NULL, NULL, whInstance,  NULL);
}

?? anyone ? :(
Maybe I'm missing something but why do you need the second dialog?
Dialogs are NOT created with CreateWindowEx or similar, instead use CreateDialogParam function or CreateDialog macro (for modeless dialogs). There is also DialogBox for creating modal dialogs using their own message loop.
well, perhaps i am using the wrong word.

think photoshop.

think 'brightness/contrast' adjust panel, where you enter some parameters for the program, grouped on the panel by their specific function.

it comes up, it goes away. i thought it was called a dialog.

(i do realise that a 'dialog' per se has been used as the main window in some win32 tutorials, eg. forgershut)


for my app, i want several (panels/dialogs) that can be open simultaneously. the app is for creating spherical height fields. one "dialog" pertains to the height field seed, one to eg. modifying the oceanic regions, one to climate, et c.

that's why it is nice with more than one "dialog"!

photoshop has more than one "dialog". i hope that is appreciable to you.


i guess the part that makes this difficult is that i'm using borland fclt and have chosen to make windows controls the "full" way instead of using an .rc file. this is because i use the compiler without an IDE and do not have the facility to automatically generate .rc files like vc++. because the creation of .rc files isn't well documented in my awareness, i'm buggered trying to use them.

i've been using CreateWindowEx to make my "second panel thingy" because it is the only method i have found fully documented without using an .rc file.


what single method would you recommend me using instead, that can be coded without using a resource file? :)
Last edited on
..not to seem ungrateful for your reply,

while you can easily say "dialog boxes are not created with CreateWindowEx", it is obvious that they can be as i have done so. :)

do you have any clue how i can do "whatever i'm doing" without causing the conflict between the two panels?

you can try it here -
http://www.xoxos.net/temp/map4.zip

the first panel is globe > height field

wiggle your mouse around and you'll see the functions associated with that panel..

the second panel is water > water, though, as you can see, it only duplicates the first panel..
Could both dialogs having the same class name (DialogClass) be an issue?
Since they are duplicate windows it makes sense to have a single generic CreateDialog function, and have all dialogs sharing the same window procedure. Then inside the window procedure you only need to determine which dialog the current message is for. You could use Set/GetWindowLongPtr(..., GWLP_USERDATA) for that purpose.
naraku - that's likely to be it.

previously i'd thought the string was an identifier in the same way that "button" is. while i haven't had the time to successfully rebuild it, changing this string on the first dialog doesn't break it.. so that's the answer :)
Topic archived. No new replies allowed.