Thread: figuring out what the code means

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jul 2022
    Posts
    78
    can someone explain this code for me:

    Code:
        WNDCLASSEXW wc = {0};
    
    
        wc.hbrBackground = (HBRUSH) COLOR_WINDOW ;
        wc.hCursor = LoadCursor(NULL, IDC_ARROW);
        wc.hInstance = hInst;
        wc.lpszClassName = L"myWindowClass";
        wc.lpfnWndProc = WindowProcedure;
    if there is, can tell me what the window variable name is

  2. #2
    Registered User
    Join Date
    Jan 2010
    Posts
    209

    Post

    Quote Originally Posted by WaterSerpentM View Post
    can someone explain this code for me:

    Code:
        WNDCLASSEXW wc = {0};
    
    
        wc.hbrBackground = (HBRUSH) COLOR_WINDOW ;
        wc.hCursor = LoadCursor(NULL, IDC_ARROW);
        wc.hInstance = hInst;
        wc.lpszClassName = L"myWindowClass";
        wc.lpfnWndProc = WindowProcedure;
    if there is, can tell me what the window variable name is
    It's a window class. You must register a window class before you can create a window. The background colour is set using the HBRUSH part, and then the cursor type after that (in your code). IDC_ARROW is the most common, probably the cusor type you're using right now. The hInstance part is (if I remember correctly) a handle to the application your making that your window will run in. Its variable type is of type HINSTANCE.

    Windows Data Types (BaseTsd.h) - Win32 apps | Microsoft Learn

    Scroll down until you find it. It's not all that helpful to be honest, just know that the HINSTANCE hInst in your code is very important and is something your window class will want. Then the class is given a name. In this case it's "myWindowClass".

    Note the L before it means the string will be converted into a wide character string. The last part:

    Code:
    wc.lpfnWndProc = WindowProcedure;
    Determines which message handling function you want to use to handle messages sent to the window. You have to make this yourself although most IDE's (the place where you write your code) I imagine make one for you as an example.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 09-04-2019, 07:56 AM
  2. Replies: 11
    Last Post: 04-22-2012, 10:41 AM
  3. figuring out code
    By Thegame16 in forum C Programming
    Replies: 16
    Last Post: 09-23-2011, 06:47 PM
  4. What does this code means?
    By junkeat90 in forum C++ Programming
    Replies: 6
    Last Post: 01-14-2008, 05:03 AM
  5. What does this code means??
    By dianazheng in forum C Programming
    Replies: 13
    Last Post: 10-12-2004, 09:45 PM

Tags for this Thread