Results 1 to 6 of 6

Thread: Create New Form

  1. #1

    Thread Starter
    Hyperactive Member Wak's Avatar
    Join Date
    Nov 2000
    Location
    Brisbane, Queensland
    Posts
    298

    Unhappy

    Hi,
    I am like ultra super dugger at this C++ stuff, so I am here to ask a few questions.

    1.)How can I create a new from with a command button and a text box, using API, and what lib files/include files, do I have to include.

    2.)How can I trap message events, using whatever methods, other than the MFC stuff. I'm trying to steer away from that.

    3.) Anything else that even remotley links to this topic. plz Post it. What the hell, even if it isn't. But as long as it does something.

    Thanx all
    Visual Basic 6.0 Enterprise
    Visual C++ 6.0 Professional

    Wak

  2. #2
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Dugger? Is that an Aussie term? I'm guessing it means you don't know much about it.

    Okay, this is the standard response to people who don't know much about C++ and want to know how to make Windows-based programs: learn C++ to a reasonably good standard before you start to program Windows apps. You need to have a fairly solid understanding of classes and pointers for instance.

    Since I'm not really sure what 'dugger' means, I'm not sure what you know about C++ already. Maybe it means you know C++ already.

    Firstly, there are a couple of VB things that are really misrepresentations of the way Windows works. Basically, there's not really such a thing as a form. They're windows. Everything is a window, even the buttons. Well you probably knew that already. To create a form with a button and a text box on it, you need to create three windows. The form is that parent window, and you can create your own window class for that, then register it, then create the window from your class. The button and textbox are predefined window classes which you create instances of.

    You trap Windows messages using a message loop (or 'message pump') which goes in your WinMain() function, the foundation of your application. You get the messages from the message queue using either GetMessage() or PeekMessage(). The various parts of a message structure tell you what kind of message it is.

    The file you need to include for Windows stuff is windows.h. This gives you access to pretty much all the API functions. You may need to include other header files for maths and stuff, or for non-GDI graphics (DirectX, OpenGL) or generally non core Windows stuff.
    Harry.

    "From one thing, know ten thousand things."

  3. #3

    Thread Starter
    Hyperactive Member Wak's Avatar
    Join Date
    Nov 2000
    Location
    Brisbane, Queensland
    Posts
    298

    Unhappy Dugger & Dynamic Window API

    All,
    The word dugger was created cause there were these brothers at my school, about 50 yrs ago, and anyway they were really crap at everything, and their surnames were dugger. Anyway the meaning has evolved since then.

    I knew pretty what you have said already, but it still helped, because it wasn't concrete to me. Anyway, it would be greate if someone could send me an App, that shows this, or posts the code. This is really what I am looking for, cause I find it really hard, so figure out how all the API parameters fit in.

    Thanx all for your help.
    Visual Basic 6.0 Enterprise
    Visual C++ 6.0 Professional

    Wak

  4. #4

    Thread Starter
    Hyperactive Member Wak's Avatar
    Join Date
    Nov 2000
    Location
    Brisbane, Queensland
    Posts
    298

    Another Question - Sorry

    It just accured to me, as I stared up my first real Win 32 Application. How do I get the compiler to start. Do I just head the Class, Main, or to I had to do something different.
    Visual Basic 6.0 Enterprise
    Visual C++ 6.0 Professional

    Wak

  5. #5
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    The applications first entry-point is the WinMain Function (same as Main in console apps).
    Code:
    WinMain
    The WinMain function is called by the system as the initial entry point for a Win32-based application. 
    
    int WINAPI WinMain(
      HINSTANCE hInstance,  // handle to current instance
      HINSTANCE hPrevInstance,  // handle to previous instance
      LPSTR lpCmdLine,      // pointer to command line
      int nCmdShow          // show state of window
    );
     
    Parameters
    hInstance 
    Handle to the current instance of the application. 
    hPrevInstance 
    Handle to the previous instance of the application. For a Win32-based application, this parameter is always NULL. 
    If you need to detect whether another instance already exists, create a uniquely named mutex using theCreateMutex function. CreateMutex will succeed even if the mutex already exists, but theGetLastError function will return ERROR_ALREADY_EXISTS. This indicates that another instance of your application exists, because it created the mutex first. 
    
    lpCmdLine 
    Pointer to a null-terminated string specifying the command line for the application, excluding the program name. To retrieve the entire command line, use theGetCommandLine function. 
    nCmdShow 
    Specifies how the window is to be shown. This parameter can be one of the following values: Value Meaning 
    SW_HIDE Hides the window and activates another window. 
    SW_MINIMIZE Minimizes the specified window and activates the top-level window in the system's list. 
    SW_RESTORE Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position (same as SW_SHOWNORMAL). 
    SW_SHOW Activates a window and displays it in its current size and position. 
    SW_SHOWMAXIMIZED Activates a window and displays it as a maximized window. 
    SW_SHOWMINIMIZED Activates a window and displays it as an icon. 
    SW_SHOWMINNOACTIVE Displays a window as an icon. The active window remains active. 
    SW_SHOWNA Displays a window in its current state. The active window remains active. 
    SW_SHOWNOACTIVATE Displays a window in its most recent size and position. The active window remains active. 
    SW_SHOWNORMAL Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position (same as SW_RESTORE). 
    
    
    Return Values
    If the function succeeds, terminating when it receives a WM_QUIT message, it should return the exit value contained in that message's wParam parameter. If the function terminates before entering the message loop, it should return zero. 
    
    Remarks
    Your WinMain should initialize the application, display its main window, and enter a message retrieval-and-dispatch loop that is the top-level control structure for the remainder of the application's execution. Terminate the message loop when it receives a WM_QUIT message. At that point, your WinMain should exit the application, returning the value passed in the WM_QUIT message's wParam parameter. If WM_QUIT was received as a result of calling PostQuitMessage, the value of wParam is the value of the PostQuitMessage function's nExitCode parameter. For more information, see Creating a Message Loop.
    
    ANSI applications can use the lpCmdLine parameter of the WinMain function to access the command-line string, excluding the program name. The reason that WinMain cannot return Unicode strings is that lpCmdLine uses the LPSTR data type, not the LPTSTR data type. The GetCommandLine function can be used to access Unicode strings in the command line, because it uses the LPTSTR data type. 
    
    Windows CE: Windows CE does not support the following values for the nCmdShow parameter: 
    
    SW_MINIMIZE 
    
    SW_RESTORE 
    
    SW_SHOWMAXIMIZED 
    
    SW_SHOWMINIMIZED 
    
    SW_SHOWMINNOACTIVE
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  6. #6
    Member
    Join Date
    Jan 2001
    Location
    Washington, USA
    Posts
    61

    check out this book

    Programming Windows, The Definitive Guide to the Win32 API
    by Charles Petzold

    It is the perfect book for Win32 API programming.

    I highly recommend it.

    Samwise Galenorn
    [email protected]

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