Advertisement

Dialog window without MFC

Started by September 25, 2000 02:23 PM
9 comments, last by SteveBrown 24 years, 3 months ago
Is this possible, MFC is really annoying me. I didn''t even start an MFC project and for some reason it is in there. The file StdAfx.h was a real pain, since I had to find it in another app and copy it where it wasn''t in my project. Now it keeps telling me not to include windows.h and I don''yt have it included ANYWHERE in my program. Can someone help me out by either telling me how to get rid of MFC or what I am doing wrong with it?
Your question is not massively clear, but here''s one thought - when you create a new class are you using class wizard? If so, is it giving you a choice of what class to inherit from? If you inherit from one of the MFC classes you are screwed.

Otherwise, please repost your question with a little more step by step detail of what is happening.

"That ain't soup du jour. I had soup du jour once. It was chicken"
"It's obvious isn't it Miller? Curiosity killed these cats!"
Advertisement
I am using a class for the dialog box. The class is derived from CDialog. I geuss this is an MFC class right? Is there an alternative class?
Windows program usually should #include windows.h .
Maybe you understand the message wrong. Maybe it tells you to include windows.h .
And I think you don''t need stdAfx.h if You also delete it from visual c++''s file list also
God saw all that he had made. Shit happens sometimes. --the sixth day.
Steve - yes CDialog is an MFC class. You don''t have to derive your class from anything. You don''t actually have to have a class at all, just a dialog proc and a CreateDialog call in your program. Just remember you will have to do all the stuff that MFC was doing for you before - sorry - it''s been a while since I MFC''ed and I don''t remember how CDialogs were implemented exactly.

"It's obvious isn't it Miller? Curiosity killed these cats!"
"It's obvious isn't it Miller? Curiosity killed these cats!"
Thanks for replying!

It does tell me not to include windows.h. I had to have StdAfx.h, I got an error saying missing file StdAfx.h and errors saying CDialog and other objects did not exist. In the StdAfx.h file it says

#if def _WINDOWS_
error (or some code, can''t remeber exactly) SHOULD NOT INCLUDE WINDOWS.h // something like this

How much trouble is it to run a dialog box without MFC? Anyone have any suggestions about using MFC or links to tutorials about MFC and dialog boxes?
Advertisement
Check out www.relisoft.com for some good tutorials on Win32 without MFC. I''m pretty sure they have some dialog box stuff. It''s not hard at all, BTW.

"It's obvious isn't it Miller? Curiosity killed these cats!"
"It's obvious isn't it Miller? Curiosity killed these cats!"
A. Make a resource dialogbox
B. Code a DialogProc(...)
C. Use Win32 DialogBox(...) function.

    //---------------------------------------------------------------------------BOOL CALLBACK DlgProcAbout(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam){	switch(uMsg)	{	case WM_INITDIALOG:		{				return TRUE;		}		case WM_COMMAND:			switch(LOWORD(wParam))	//HIWORD(wParam)==BN_CLICKED			{	case IDOK:				case IDCANCEL:					EndDialog(hDlg, 0);					return TRUE;			}			break;	}	return FALSE;}//---------------------------------------------------------------------------    


Arg

I can''t seem to get my dialog to display. I have put a little message box into the case WM_INITDIALOG, and it shows up. There is also a listing on my task list that shows my app-ish thing is still running...

    #include <windows.h>#include <string.h>#include <stdio.h>#include "resource.h"BOOL CALLBACK DialogFunc(HWND, UINT, WPARAM, LPARAM);char WindowName[] = "Dialog Test";HWND hwnd;int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,				   LPSTR Args, int WinMode){	MSG msg;	hwnd = CreateDialog(hInst, MAKEINTRESOURCE(MAINDIALOG), 	NULL, DialogFunc);	int status;		while((status = GetMessage(&msg, NULL, 0, 0)) != 0)	{		if(status == -1)			return -1;		if(!IsDialogMessage(hwnd, & msg))		{            TranslateMessage(&msg);            DispatchMessage(&msg);        }	}	return msg.wParam;}BOOL CALLBACK DialogFunc(HWND hdwnd, UINT message,						 WPARAM wParam, LPARAM lParam){	switch(message)  {	case WM_INITDIALOG:		SendDlgItemMessage(hdwnd, LIST1,			LB_ADDSTRING, 0, (LPARAM)"Apple");		SendDlgItemMessage(hdwnd, LIST1,			LB_ADDSTRING, 0, (LPARAM)"Agent1");		SendDlgItemMessage(hdwnd, LIST1,			LB_ADDSTRING, 0, (LPARAM)"Ima Genius");        return TRUE;    case WM_DESTROY:        PostQuitMessage(0);        return TRUE;    case WM_CLOSE:        DestroyWindow(hwnd);        return TRUE;	}	return FALSE;}    


Have I made any glaring errors?

(Don''t yell too loudly, I''m still learning )



-Agent1




Operator: You have a telegram.
Encrypted Transmission from Agent1, sent Wed Sep 6, 2000 7:38 PM:
Agent1: *Speeds through section on Message Loops*
Agent1: Soon I'll be using Property Sheets! :)
Byte Me: *been using them since he was a wee lad*


[art]: Take it out, then shove it in a day or two.
[art]: *Operates on his brains.
I believe you have to have a ShowWindow after your CreateDialog. Not totally sure, though.

"It's obvious isn't it Miller? Curiosity killed these cats!"
"It's obvious isn't it Miller? Curiosity killed these cats!"

This topic is closed to new replies.

Advertisement