Results 1 to 3 of 3

Thread: chopping it up :)

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2002
    Posts
    3

    chopping it up :)

    ok heres the problem im not using mfc but am using the wizard to create a basic app then trying to edit it in ms vc++

    i have messed arounf with the code and am trying to get 1 window with no menus and a usable main window so i can add check boxes and form elecments..... i know c++ fairly well and thought i get to grips with vc++....

    heres the code which must have loads and loads of errors, it compiles though but just hangs...

    oh i have all the files including a resource file with the form that im trying to incvlude, basically im trying to get used to the way things work but no matter how much ive messed with this it the form either disapears or the app doesnt do anything.....

    thanks for any input.... i have done a couple of tutorials but i cant find any which explain how to draw things in the middle of the window like a button which does something to a text field.....

    PHP Code:
    // logonscript.cpp : Defines the entry point for the application.
    //

    #include "stdafx.h"
    #include "resource.h"

    #define MAX_LOADSTRING 100

    // Global Variables:
    HINSTANCE hInst;
    TCHAR szTitle[MAX_LOADSTRING];                                // The title bar text
    TCHAR szWindowClass[MAX_LOADSTRING];                    // current instance

    // Foward declarations of functions included in this code module:
    ATOM                MyRegisterClass(HINSTANCE hInstance);
    BOOL                InitInstance(HINSTANCEint);
    LRESULT CALLBACK    WndProc(HWNDUINTWPARAMLPARAM);
    LRESULT CALLBACK    Formview(HWNDUINTWPARAMLPARAM);

    int APIENTRY WinMain(HINSTANCE hInstance,
                         
    HINSTANCE hPrevInstance,
                         
    LPSTR     lpCmdLine,
                         
    int       nCmdShow)
    {
         
        
    // TODO: Place code here.
        
    MSG msg;
        
    HACCEL hAccelTable;

        
    // Initialize global strings
        
    LoadString(hInstanceIDC_LOGONSCRIPTszWindowClassMAX_LOADSTRING);
        
    LoadString(hInstanceIDC_LOGONSCRIPTszWindowClassMAX_LOADSTRING);
            
    MyRegisterClass(hInstance);

        
    // Perform application initialization:
        
    if (!InitInstance (hInstancenCmdShow)) 
        {
            return 
    FALSE;
        }

        
    hAccelTable LoadAccelerators(hInstance, (LPCTSTR)IDC_LOGONSCRIPT);

        
    // Main message loop:
        
    while (GetMessage(&msgNULL00)) 
        {
            if (!
    TranslateAccelerator(msg.hwndhAccelTable, &msg)) 
            {
                
    TranslateMessage(&msg);
                
    DispatchMessage(&msg);
            }
        }

        return 
    msg.wParam;
    }



    //
    //  FUNCTION: MyRegisterClass()
    //
    //  PURPOSE: Registers the window class.
    //
    //  COMMENTS:
    //
    //    This function and its usage is only necessary if you want this code
    //    to be compatible with Win32 systems prior to the 'RegisterClassEx'
    //    function that was added to Windows 95. It is important to call this function
    //    so that the application will get 'well formed' small icons associated
    //    with it.
    //
    ATOM MyRegisterClass(HINSTANCE hInstance)
    {
        
    WNDCLASSEX wcex;

        
    wcex.cbSize sizeof(WNDCLASSEX); 

        
    wcex.style            CS_HREDRAW CS_VREDRAW;
        
    wcex.lpfnWndProc    = (WNDPROC)WndProc;
        
    wcex.cbClsExtra        0;
        
    wcex.cbWndExtra        0;
        
    wcex.hInstance        hInstance;
        
    wcex.hIcon            LoadIcon(hInstance, (LPCTSTR)IDI_LOGONSCRIPT);
        
    wcex.hCursor        LoadCursor(NULLIDC_ARROW);
        
    wcex.hbrBackground    = (HBRUSH)(COLOR_WINDOW+1);
        
    wcex.lpszMenuName    = (LPCSTR)IDC_LOGONSCRIPT;
        
    wcex.lpszClassName    szWindowClass;
        
    wcex.hIconSm        LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
        
        return 
    RegisterClassEx(&wcex);
    }

    //
    //   FUNCTION: InitInstance(HANDLE, int)
    //
    //   PURPOSE: Saves instance handle and creates main window
    //
    //   COMMENTS:
    //
    //        In this function, we save the instance handle in a global variable and
    //        create and display the main program window.
    //
    BOOL InitInstance(HINSTANCE hInstanceint nCmdShow)
    {
       
    HWND hWnd;

       
    hInst hInstance// Store instance handle in our global variable

       
    hWnd CreateWindow(szWindowClassszTitleWS_OVERLAPPEDWINDOW,
       
    CW_USEDEFAULT0CW_USEDEFAULT0NULLNULLhInstanceNULL);

       if (!
    hWnd)
       {
          return 
    FALSE;
       }

       
    ShowWindow(hWndnCmdShow);
       
    UpdateWindow(hWnd);
      
       
       return 
    TRUE;
    }

    //
    //  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
    //
    //  PURPOSE:  Processes messages for the main window.
    //
    //  WM_COMMAND    - process the application menu
    //  WM_PAINT    - Paint the main window
    //  WM_DESTROY    - post a quit message and return
    //
    //
    LRESULT CALLBACK WndProc(HWND hWndUINT messageWPARAM wParamLPARAM lParam)
    {
        
    int wmIdwmEvent;
        
    PAINTSTRUCT ps;
        
    HDC hdc;

        switch (
    message
        {
            
    DialogBox(hInst, (LPCTSTR)IDD_FORMVIEWhWnd, (DLGPROC)Formview);
            case 
    WM_COMMAND:
                
    wmId    LOWORD(wParam); 
                
    wmEvent HIWORD(wParam); 
            
            case 
    WM_PAINT:
                
    hdc BeginPaint(hWnd, &ps);
                 
    //TODO: Add any drawing code here...
            
                
    DialogBox(hInst, (LPCTSTR)IDD_FORMVIEWhWnd, (DLGPROC)Formview);

                
    RECT rt;
                
    GetClientRect(hWnd, &rt);
                
                
    EndPaint(hWnd, &ps);
                break;
            case 
    WM_DESTROY:
                
    PostQuitMessage(0);
                break;
            default:
                return 
    DefWindowProc(hWndmessagewParamlParam);
       }
       return 
    0;
    }



    LRESULT CALLBACK Formview(HWND hDlgUINT layoutWPARAM wParamLPARAM lParam)
    {
        switch (
    layout)
        {
            
            case 
    WM_COMMAND:
                if (
    LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL
                {
                    
    EndDialog(hDlgLOWORD(wParam));
                    return 
    TRUE;
                }
                break;
        }
        return 
    FALSE;

    thanks
    :: The www.tekforums.com Colective ::

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    BTW you usually don't add controls to the main window. You use dialogs for that.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2002
    Posts
    3
    lol i leanrt that the hardware after messing around i finally got rid of that whole piece of code and started again....
    :: The www.tekforums.com Colective ::

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