   Window class help???
  I'm trying to make it easy to create and use a window with a class. So I tried to code it and I only get one error. It is a conversion error between my WndProc and what the class expects. Can someone tell me what I did wrong. Here's my code: #define WIN32_LEAN_AND_MEAN#include<windows.h>class appWindow{private:WNDCLASS wc;MSG msg;HWND hwnd;public:LRESULT CALLBACK WndProc(HWND hWnd,UINT imsg, WPARAM wParam,LPARAM lParam){switch(imsg){case WM_DESTROY:PostQuitMessage(0);break;}return DefWindowProc(hWnd,imsg,wParam,lParam);}void SetUp(HINSTANCE hinst){wc.cbClsExtra = 0;wc.cbWndExtra = 0;wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);wc.hCursor = LoadCursor(NULL,IDC_ARROW);wc.hIcon = LoadIcon(NULL,IDI_APPLICATION);wc.hInstance = hinst;wc.lpfnWndProc = WndProc;wc.lpszClassName = "Class";wc.lpszMenuName = NULL;wc.style = CS_VREDRAW|CS_HREDRAW;RegisterClass(&wc);hwnd = CreateWindow("Class","Window",WS_OVERLAPPEDWINDOW,0,0,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hinst,NULL);}void DisplayWindow(int i){UpdateWindow(hwnd);ShowWindow(hwnd,i);if(GetMessage(&msg,NULL,0,0)){TranslateMessage(&msg);DispatchMessage(&msg);}}}window;int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hpInstance,PSTR cmdline,int iCmd){window.SetUp(hInstance);   window.DisplayWindow(iCmd);return 0;}Here is the error:   C:\Program Files\Microsoft Visual Studio\MyProjects\WindowClass\WindowClass.cpp(24) : error C2440: '=' : cannot convert from 'long (__stdcall appWindow::*)(struct HWND__ *,unsigned int,unsigned int,long)' to 'long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'   There is no context in which this conversion is possibleThanks you guys.Cory   Favorite Quotes:Gandalf: You shall not pass!|Smeagol: We don't need you!|Sloth: Hey you guys!|[edited by - ssjcory on February 14, 2004 12:05:27 AM]
  Ok i found that if I just create that message handler outside the class then it works for some odd reason. Also the window shows for like 1 second and then closes why?   Favorite Quotes:Gandalf: You shall not pass!|Smeagol: We don''t need you!|Sloth: Hey you guys!|;  Ok, I don''t know too much about Windows programming (I''m kind of a newbie myself), but I''ll venture a guess:Shouldn''tint WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hpInstance,PSTR cmdline,int iCmd){window.SetUp(hInstance);   window.DisplayWindow(iCmd);return 0;instead be int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hpInstance,LPSTR cmdline,int iCmd){window.SetUp(hInstance);   window.DisplayWindow(iCmd);return 0;?  (PSTR cmdline should be LPSTR cmdline).If I''m wrong, sorry I couldn''t be of any more help.-Gauvir_Mucca ;  Nah thats not it that just declares it as A PSTR pointer to a string instead of a LPSTR long pointer to a string. DOesn''t matter. PROPS for trying tho.   Favorite Quotes:Gandalf: You shall not pass!|Smeagol: We don''t need you!|Sloth: Hey you guys!|;  If you are going to post your WndProc inside a class make it static. The callback is declared as WndProc(something something), but when you define it inside a class the ''this'' pointer gets passed to it unless its static, and if it is not static thats where you get an error as the WndProc class you defined doesn''t have the same function prototype that the function pointer it wants expects.Sorry really late tonight so I may sound incoherent.   In the making Tread Wars - Tank Battle gamePowered by SKEnginehttp://www.highendgaming.com;  Stupid me shoulda put while stead of if. Thanks guys.Favorite Quotes:Gandalf: You shall not pass!|Smeagol: We don't need you!|Sloth: Hey you guys!| [edited by - ssjcory on February 14, 2004 12:28:06 AM];  How do I make it so that i can include a file that I made in to a project. Ok for example #include. I want to be able to do that for my window class. How do I do that? Do I just make a AppWindow.h that has all of the declarations in it? If so I tried that moved it to the folder of the project that I wanted to use it in and it doesn''t work, I get unresolved external symbol. BTW since it was in the folder I used #include"AppWindow.h"I don''t know how to make it work, plz help.Cory   Favorite Quotes:Gandalf: You shall not pass!|Smeagol: We don''t need you!|Sloth: Hey you guys!|