Thread: First VC++ progy

  1. #1

    First VC++ progy

    ok i have no clue what to do, all i want to do is have text in the dialog box. simple as that.
    Code:
    #include <windows.h>
    
    /* Declare Windows procedure */
    LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
    /* Make the class name into a global variable */
    char szClassName[ ] = "WindowsApp";
    int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil)
    
    {
        HWND hwnd;               /* This is the handle for our window */
        MSG messages;            /* Here messages to the application are saved */
        WNDCLASSEX wincl;        /* Data structure for the windowclass */
    
        /* The Window structure */
        wincl.hInstance = hThisInstance;
        wincl.lpszClassName = szClassName;
        wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
        wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
        wincl.cbSize = sizeof(WNDCLASSEX);
    
        /* Use default icon and mouse-pointer */
        wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
        wincl.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
        wincl.hCursor = LoadCursor(NULL, IDC_ARROW);
        wincl.lpszMenuName = NULL; /* No menu */
        wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
        wincl.cbWndExtra = 0;                      /* structure or the window instance */
        /* Use light-gray as the background of the window */
        wincl.hbrBackground = (HBRUSH) GetStockObject(LTGRAY_BRUSH);
    
        /* Register the window class, if fail quit the program */
        if(!RegisterClassEx(&wincl)) return 0;
    
        /* The class is registered, let's create the program*/
        hwnd = CreateWindowEx(
               0,                   /* Extended possibilites for variation */
               szClassName,         /* Classname */
               "Alanna Is Hawt~!",         /* Title Text */
               WS_OVERLAPPEDWINDOW, /* default window */
               CW_USEDEFAULT,       /* Windows decides the position */
               CW_USEDEFAULT,       /* where the window ends up on the screen */
               250,                 /* The programs width */
               100,                 /* and height in pixels */
               HWND_DESKTOP,        /* The window is a child-window to desktop */
               NULL,                /* No menu */
               hThisInstance,       /* Program Instance handler */
               NULL                 /* No Window Creation data */
               );
    
        /* Make the window visible on the screen */
        ShowWindow(hwnd, nFunsterStil);
        /* Run the message loop. It will run until GetMessage( ) returns 0 */
        while(GetMessage(&messages, NULL, 0, 0))
        {
               /* Translate virtual-key messages into character messages */
               TranslateMessage(&messages);
               /* Send message to WindowProcedure */
               DispatchMessage(&messages);
        }
    
        MessageBox (NULL, "You are very very sexy" , "You are hawt!", 0 + MB_ICONASTERISK);
        MessageBox (NULL, "You are very very sexy" , "You are hawt!", 0 + MB_ICONASTERISK);
        MessageBox (NULL, "You are very very sexy" , "You are hawt!", 0 + MB_ICONASTERISK);
        MessageBox (NULL, "You are very very sexy" , "You are hawt!", 0 + MB_ICONASTERISK);
        MessageBox (NULL, "You are very very sexy" , "You are hawt!", 0 + MB_ICONASTERISK);
        MessageBox (NULL, "You are very very sexy" , "You are hawt!", 0 + MB_ICONASTERISK);
        MessageBox (NULL, "You are very very sexy" , "You are hawt!", 0 + MB_ICONASTERISK);
        MessageBox (NULL, "You are very very sexy" , "You are hawt!", 0 + MB_ICONASTERISK);
        MessageBox (NULL, "You are very very sexy" , "You are hawt!", 0 + MB_ICONASTERISK);
        /* The program return-value is 0 - The value that PostQuitMessage( ) gave */
        return messages.wParam;
    }
    
    /* This function is called by the Windows function DispatchMessage( ) */
    LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
        switch (message)                  /* handle the messages */
        {
               case WM_DESTROY:
               PostQuitMessage(0);        /* send a WM_QUIT to the message queue */
               break;
               default:                   /* for messages that we don't deal with */
               return DefWindowProc(hwnd, message, wParam, lParam);
        }
        return 0;
    }
    yes alanna is hawt

  2. #2
    julie lexx... btq's Avatar
    Join Date
    Jun 2002
    Posts
    161
    you want it to show all them boxes when you quit?
    and I really dont see the dialog...be more specific about your
    problem..

    /btq
    ...viewlexx - julie lexx

  3. #3
    yah those boxers are spose to be there, well when i compile and execute u know, the program dialog comes up, but its just a blank dialog, i want to put text on the dialog

  4. #4
    julie lexx... btq's Avatar
    Join Date
    Jun 2002
    Posts
    161
    when you execute this program you should get an empty
    window..
    when you close it a bunch of MessageBoxes will appear..
    this isn't what you want?


    /btq
    ...viewlexx - julie lexx

  5. #5
    i dont want the empty window, i want one line of text in it

  6. #6
    julie lexx... btq's Avatar
    Join Date
    Jun 2002
    Posts
    161
    i dont want the empty window, i want one line of text in it
    well code it then
    look up TextOut() or DrawText() and you're set..

    /btq
    ...viewlexx - julie lexx

  7. #7
    where would i place it?

  8. #8
    julie lexx... btq's Avatar
    Join Date
    Jun 2002
    Posts
    161
    do something like:
    Code:
    LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    HDC hdc;
    PAINTSTRUCT ps;
    RECT rect;
    SetRect(&rect,0,0,60,20);
    LPCSTR str = "text goes here";
    
        switch (message)                  /* handle the messages */
        {
               case WM_PAINT:
               hdc=BeginPaint(hwnd,&ps);             
               TextOut(hdc,str,strlen(str),&rect,DT_CENTER);
               EndPaint(hwnd,hdc);
               break;
    
               case WM_DESTROY:
               PostQuitMessage(0);        /* send a WM_QUIT to the message queue */
               break;
               default:                   /* for messages that we don't deal with */
               return DefWindowProc(hwnd, message, wParam, lParam);
        }
        return 0;
    }
    /btq
    Last edited by btq; 10-24-2002 at 03:30 PM.
    ...viewlexx - julie lexx

  9. #9
    looking at my code up there, what is my *.HDC ? cause textout() needs this textout(*.HDC , x, y,"text", size(orsomething)), so whats my HDC??

  10. #10
    julie lexx... btq's Avatar
    Join Date
    Jun 2002
    Posts
    161
    see my prevoius post
    maybe you should check this

    /btq
    ...viewlexx - julie lexx

  11. #11
    Registered User Bajanine's Avatar
    Join Date
    Dec 2001
    Location
    The most peaks over 10,000 feet!
    Posts
    396

    Great link.

    Is this the 'Sunlight' that used to frequent this forum?

  12. #12
    julie lexx... btq's Avatar
    Join Date
    Jun 2002
    Posts
    161
    Is this the 'Sunlight' that used to frequent this forum?
    not quite shure I follow you...what do you mean?
    /btq
    ...viewlexx - julie lexx

  13. #13
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    >>> Is this the 'Sunlight' that used to frequent this forum?

    Yes.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  14. #14
    Registered User
    Join Date
    Oct 2002
    Posts
    8
    *whispers someting about wxwindows

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. built-in variables for VC?
    By George2 in forum Tech Board
    Replies: 1
    Last Post: 08-20-2006, 05:02 AM
  2. makefile exported by vc 6.0 doesn't work
    By wow in forum Windows Programming
    Replies: 7
    Last Post: 03-24-2006, 04:20 PM
  3. VC to Borland
    By Lurker in forum Tech Board
    Replies: 0
    Last Post: 01-19-2004, 02:57 PM
  4. Can't compile this with VC 6.0
    By uriel2013 in forum C++ Programming
    Replies: 4
    Last Post: 05-31-2003, 07:43 PM
  5. Why VC?
    By Unregistered in forum Windows Programming
    Replies: 1
    Last Post: 04-15-2002, 05:24 AM