Archived

This topic is now archived and is closed to further replies.

Rydis

WinApi Dialogboxes

Recommended Posts

how do you create a dialog box thats not transparent im using the CreateDialog Function and pass the template as a MAKEINTRESOURCE i then use show window but when the program runes the buttons and text onthe dialog box appears but it has no border what so ever and if you drag window away the dialog borders and everything but the buttons and such is transparent.
#include <windows.h>
#include "resource.h"

long WINAPI MainWinProc (HWND hWnd, UINT msg, WPARAM wParam, 
						 LPARAM lParam);

HWND Window1, Dialog;

int CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 
				   LPSTR lpCmdLine, int nCmdShow)

{
	WNDCLASS wc;

	wc.style = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc = MainWinProc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = hInstance;
	wc.hIcon = NULL;
	wc.hCursor = LoadCursor (NULL, IDC_ARROW);
	wc.hbrBackground = (HBRUSH) (COLOR_WINDOW +1);
	wc.lpszMenuName = NULL;
	wc.lpszClassName = "szWindowClass";

	RegisterClass(&wc);

	Window1=CreateWindow("szWindowClass", "Main", WS_BORDER|
		WS_CAPTION, CW_USEDEFAULT, NULL, CW_USEDEFAULT, NULL, NULL,
		NULL, hInstance, NULL);

	Dialog = CreateDialogIndirect(hInstance, MAKEINTRESOURCE(101), NULL, DialogProc);

	ShowWindow(Window1, nCmdShow);
	UpdateWindow(Window1);

	ShowDialog(
	UpdateWindow(Dialog);


	MSG msg;
	while (GetMessage(&msg, NULL, 0,0))
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}
	return msg.wParam;

}

long WINAPI MainWinProc (HWND hWnd, UINT msg, WPARAM wParam, 
						 LPARAM lParam)
{
	switch (msg)
	{
	case WM_COMMAND:
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;
	default:
		return DefWindowProc(hWnd, msg, wParam, lParam);
	}

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

int CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch(uMsg)
	{
	case WM_COMMAND:
		switch(wParam)
		{
			case IDOK:
				break;
			case IDCANCEL:
				break;
			case Close:
				DestroyWindow(Dialog);
				PostQuitMessage(0);
				break;
		}
	}
	return true;
}

Share this post


Link to post
Share on other sites
Transparent dialog eh?

Well if you do some research on teh google you will find out what''s wrong but I''m going to be nice and fetch some links for ya...First what are you trying to make? a)normal dialog or b)modeless dialog?

if a go here
if b go here

You might as well take step c and work your way through the tutorial if you like. click

btw I think you are better off using an identifier instead of a number to refer to your resources makes the code more readable just a suggestion...


Share this post


Link to post
Share on other sites
im guessin it is a modeless dialog box. Need to do a school project that is dialog-based. Accepts in payment, tax deduction, join stock, direct deposites, ect. These all gotten through varoius dialog boxes. I can do dialog but ya, the only parts that show is the buttons, text, lists, ect. No borders no nothing. Ill check them links out in a bit kinda busy now.

Share this post


Link to post
Share on other sites
You probably have, in your resource file, the transparent dialogbox option selected. Check to see if you have "WS_EX_TRANSPARENT" in your extended styles; delete it if it is there.

Share this post


Link to post
Share on other sites