Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

adholioshake: here is what you asked for

Status
Not open for further replies.

tunahead

Programmer
Feb 22, 2003
9
AT
error C2146: syntax error : missing ';' before identifier 'CreateMainWindow'
error C2501: 'HWND' : missing storage-class or type specifiers
fatal error C1004: unexpected end of file found
Error executing cl.exe.
 
I have fixed this procedure code...
Code:
// Main.h
HWND CreateMainWindow(HINSTANCE);

HWND CreateMainWindow(HINSTANCE hinst)
{
  WNDCLASSEX wndClass;

  wndClass.cbSize=sizeof(WNDCLASSEX); //Größe angeben
  wndClass.style =CS_DBLCLKS | CS_OWNDC| CS_HREDRAW | 
                  CS_VREDRAW;
  wndClass.lpfnWndProc=wndprocMain;
  wndClass.cbClsExtra=0;
  wndClass.cbWndExtra=0;
  wndClass.hInstance=hinst;
  wndClass.hbrBackground=(HBRUSH)
               GetStockObject(WHITE_BRUSH);
  wndClass.hCursor=LoadCursor(NULL, IDC_ARROW);
  wndClass.lpszMenuName=NULL;
  wndClass.lpszClassName="WindowClass";
  wndClass.hIcon=LoadIcon(NULL, IDI_WINLOGO);
  wndClass.hIconSm=LoadIcon(NULL, IDI_WINLOGO);
  if(!RegisterClassEx(&wndClass))
    return(FALSE);
  return(CreateWindowEx(NULL,"WindowClass","Fenter",
        WS_OVERLAPPEDWINDOW | WS_VISIBLE,0,0,400,300,
                 NULL, NULL,hinst,NULL));
}
I suggest just copying this into an include file, and including it into you program file after you've included <windows.h>. Here is a sample main program I have wrote to demonstrate.
Code:
// Main.cpp
#include <windows.h>
// any other headers...
#include &quot;main.h&quot;
// Prototype here:
LRESULT CALLBACK wndprocMain(HWND, UINT, WPARAM, LPARAM);

// Main Program entry:
int WINAPI WinMain(HINSTANCE hinstNew, HINSTANCE hinstOld,
                     LPSTR cmd, int show)
{
  MSG msg;
  HWND hwndMain
  if(!(hwndMain=CreateMainWindow(hinstNew)))
    return(FALSE);

  while(GetMessage(&msg, 0, 0, 0))
  {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
  }
  return(TRUE)
}

// Main window procedure:
LRESULT CALLBACK wndprocMain(HWND hwnd, UINT msg, 
                        WPARAM wparam, LPARAM lparam)
{
  return(DefWindowProc(hwnd, msg, wparam,lparam));
}
This should work with your compiler, as it works on mine.
(Sorry about the delay, I was having Tea!). Adam :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top