Results 1 to 2 of 2

Thread: FillWindow Function

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2002
    Posts
    241

    FillWindow Function

    Im too lazy to fill in these parameters over and over when I always make them the same thing. So I made this function which gets a lot of errors.

    Code:
    int FillWindow(WNDCLASSEX *wcl, LRESULT CALLBACK WndProc)
    {
    	wcl.cbSize = sizeof(WNDCLASSEX); 
    
    	wcl.hInstance = GetModuleHandle(NULL); 
    
    	wcl.lpszClassName = "classname"; 
    
    	wcl.lpfnWndProc = WndProc; 
    
    	wcl.style = 0; 
    
    	wcl.hIcon = LoadIcon(NULL, IDI_APPLICATION); 
    
    	wcl.hIconSm = LoadIcon(NULL, IDI_WINLOGO); 
    
    	wcl.hCursor = LoadCursor(NULL, IDC_ARROW); 
    
    	wcl.lpszMenuName = NULL; 
    
    	wcl.cbClsExtra = 0; 
    
    	wcl.cbWndExtra = 0; 
    
    	wcl.hbrBackground = (HBRUSH) GetStockObject(0);
    
    	return 0;
    
    }
    error C2228: left of '.cbSize' must have class/struct/union type
    c:\program files\microsoft visual studio\vc98\include\mywindows.h(22) : error C2228: left of '.hInstance' must have class/struct/union type
    c:\program files\microsoft visual studio\vc98\include\mywindows.h(24) : error C2228: left of '.lpszClassName' must have class/struct/union type
    c:\program files\microsoft visual studio\vc98\include\mywindows.h(26) : error C2228: left of '.lpfnWndProc' must have class/struct/union type
    c:\program files\microsoft visual studio\vc98\include\mywindows.h(28) : error C2228: left of '.style' must have class/struct/union type
    c:\program files\microsoft visual studio\vc98\include\mywindows.h(30) : error C2228: left of '.hIcon' must have class/struct/union type
    c:\program files\microsoft visual studio\vc98\include\mywindows.h(32) : error C2228: left of '.hIconSm' must have class/struct/union type
    c:\program files\microsoft visual studio\vc98\include\mywindows.h(34) : error C2228: left of '.hCursor' must have class/struct/union type
    c:\program files\microsoft visual studio\vc98\include\mywindows.h(36) : error C2228: left of '.lpszMenuName' must have class/struct/union type
    c:\program files\microsoft visual studio\vc98\include\mywindows.h(38) : error C2228: left of '.cbClsExtra' must have class/struct/union type
    c:\program files\microsoft visual studio\vc98\include\mywindows.h(40) : error C2228: left of '.cbWndExtra' must have class/struct/union type
    c:\program files\microsoft visual studio\vc98\include\mywindows.h(42) : error C2228: left of '.hbrBackground' must have class/struct/union type

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    You want to either use a reference (if C++), in which case pass it as WNDCLASSEX &wcl, or if it's C, you have to dereference the pointer as wcl->cbSize = sizeof(...) using the -> operator rather than the . operator.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width