Thread: win32 application wizard in microsoft visual studio

  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    222

    win32 application wizard in microsoft visual studio

    I have created a "Hello World" win32 application that is a GUI application. However, I don't understand how "Hello World" is printed inside the code. I created the application using Microsoft Visual Studio version 6 (even though you may not advise to me to do so). Any suggestions on how "Hello World" is printed in the window? I have looked on google also, but can't seem to find an answer that I understand (i.e. the descriptions aren't clear enough for me). Thanks.

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    it is windows programming - a lot of code to make a simplest thing

    go to the WndProc function - this function is called by windows in case of any event occured for the main window of the program

    Code:
    	TCHAR szHello[MAX_LOADSTRING];
    	LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
    these two lines at the beginning of the function load string "Hello, world" from resources of the exe (just in case)

    then go down to
    case WM_PAINT:
    this event notifies the application, that something was changed on the internal area (client rectangle) of the window and its content should be redrawn

    Application retreives handle of the aray and using
    Code:
    DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER);
    function draws the text loaded above in the specified location of the client area of the window
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Registered User
    Join Date
    Jul 2004
    Posts
    222
    So if I want the program to print something else, would that imply that I would have to first load the custom text into the resources of the exe?

  4. #4
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Not nessasery, but it is good practice to store all visible to enduser strings into resourses, so they could be reviewed by technical writer and translated easely into different language

    But in a sample program you can initialize the hello buffer directly instead of reading from resources
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  5. #5
    Registered User
    Join Date
    Jul 2004
    Posts
    222
    I may look back into windows programming later. It's a lot of information to absorb since I have been more accustomed to C/C++ style programming. I mainly want to make a program (either windows app or console app) that would perform event driven actions according to some flow charts that I have drafted.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Microsoft Visual Studio Professional vs Academic
    By Bajanine in forum Tech Board
    Replies: 3
    Last Post: 03-06-2009, 10:11 AM
  2. Avoiding Global variables
    By csonx_p in forum Windows Programming
    Replies: 32
    Last Post: 05-19-2008, 12:17 AM
  3. Console Font Size
    By bradszy in forum Windows Programming
    Replies: 34
    Last Post: 04-26-2008, 07:09 AM
  4. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  5. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM