Thread: skinning windows

  1. #1
    Just a Human Anuradh_a's Avatar
    Join Date
    Jan 2008
    Posts
    50

    skinning windows

    hi
    I wrote a skinned window(based on some tutorial I found on the net).Ididn't understand the
    tute very well. In my code there are two functions called clswin() and void creatergn(). when i put these functions under WM_CREATE didn't work.when i put these functions under winapi main() it worked. any one know why???
    I have attached the project.

    second question is what is the usage of bitblt()?
    and also can any on explain what exactly happen in this code??

    I'm using VC++ 6.0
    WinXp xp2
    thanks.

  2. #2
    Registered User
    Join Date
    Apr 2008
    Posts
    58
    please try to write clswin() and creatergn() in WM_CREATE event.
    why dont you develop your project on MFC?
    i think your skin windows is easy on it.

  3. #3
    Registered User
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    217
    Had a quick look and i think it's because the value of the global variable "hwnd" is only set AFTER CreateWindow is finished, but WM_CREATE is called before CreateWindow is finished (i think). The functions "creatergn" and "clswin" use this global variable. This may work:
    Code:
    void creatergn(HWND hwnd)
    {
    	
    	rgnfile =FindResource(GetModuleHandle(NULL),MAKEINTRESOURCE(IDR_RGN),"BINARY");
    	pSkinData = (LPRGNDATA)LoadResource(NULL, rgnfile);
    	rgnSkin = ExtCreateRegion(NULL, SizeofResource(GetModuleHandle(NULL),rgnfile), pSkinData);
    	SetWindowRgn(hwnd,rgnSkin,TRUE);
    	
    }
    
    void clswin(HWND hwnd)
    {
    	
    	DWORD dwStyle;
    	dwStyle = GetWindowLong(hwnd, GWL_STYLE);
    	dwStyle &= ~(WS_CAPTION|WS_SIZEBOX);
    	SetWindowLong(hwnd, GWL_STYLE, dwStyle);
    	InvalidateRect(hwnd, NULL, TRUE);
    	SetWindowPos(hwnd, NULL, 0,0,504,360, SWP_NOMOVE|SWP_NOZORDER);
    }
    
    LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
         HDC         hdc ;
         PAINTSTRUCT ps ;
    	 
    static	BOOL regned =FALSE;	 
         
    			
         switch (message)
         {
       case WM_CREATE:
    
              creatergn(hwnd);
    	  clswin(hwnd);
    	  loadbitmap();
    		
    		 		
              return 0 ;
    
    	case WM_LBUTTONDOWN:
    		  SendMessage(hwnd, WM_NCLBUTTONDOWN,HTCAPTION,0);
    		  break;
    			
         case WM_PAINT:
    			
              hdc = BeginPaint (hwnd, &ps) ;
    		  
    		  skinme(ps.hdc);
              SetBkMode(ps.hdc,TRANSPARENT);
              EndPaint (hwnd, &ps) ;
              return 0 ;
    
    		  
    			  
         case WM_DESTROY:
    		 
              PostQuitMessage (0) ;
              return 0 ;
    
    	 case WM_CLOSE:
    			DeleteDC(bitdc);
    			DeleteObject(rgnSkin);	
    			FreeResource(pSkinData);
    			  
    
         }
         return DefWindowProc (hwnd, message, wParam, lParam) ;
    		  
    }
    You need to ask yourself if it's necessary to use these global variables.
    Last edited by 39ster; 06-02-2008 at 02:26 AM.

  4. #4
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Quote Originally Posted by sgh View Post
    why dont you develop your project on MFC?
    MFC is not freeware. D'oh!
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  5. #5
    Just a Human Anuradh_a's Avatar
    Join Date
    Jan 2008
    Posts
    50
    It works. thanks guys.Making hwnd global is a bad idea right .
    thanks for showing me that.
    Is it possible to use same thing to the dialog boxes??

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Windows 98/2000 programming in Windows XP
    By Bill83 in forum Windows Programming
    Replies: 3
    Last Post: 07-22-2005, 02:16 PM
  2. Dialog Box Problems
    By Morgul in forum Windows Programming
    Replies: 21
    Last Post: 05-31-2005, 05:48 PM
  3. dual boot Win XP, win 2000
    By Micko in forum Tech Board
    Replies: 6
    Last Post: 05-30-2005, 02:55 PM
  4. SDL and Windows
    By nickname_changed in forum Windows Programming
    Replies: 14
    Last Post: 10-24-2003, 12:19 AM
  5. IE 6 status bar
    By DavidP in forum Tech Board
    Replies: 15
    Last Post: 10-23-2002, 05:31 PM