Page 39 - DCAP408_WEB_PROGRAMMING
P. 39

Unit 3: Windows Programming




                                                                                                Notes


             Notes  Observe that the string passed in lpszCmdLine is not the similar as the string returned
             by the GetCommandLine API call. The string in lpszCmdLine comprises the command-line
             arguments only (like COMMAND$), but  GetCommandLine  returns the program  name
             (counting path) followed by the arguments.

          4.   nCmdShow: It shows how to exhibit the application’s main window.


                 Example: The calling application can identify %SW_NORMAL or %SW_MINIMIZE, etc.
          It is up to the programmer to respect this parameter, and to do so is suggested.
          Return: The return value allocated to WINMAIN is optional, but by convention, the return value
          is derived from the wParam& parameter of a %WM_QUIT message.

          Usually, a GUI-based application utilizes the WINMAIN function to generate the initial GUI
          application window, and then enters a message loop. This loop should end when a %WM_QUIT
          message is obtained, and the wParam& parameter of that message should be passed on as the
          return  value for  WINMAIN. If  WINMAIN terminates  before  entering  the message  loop,
          WINMAIN should return zero.
          Console applications may utilize the return value to situate an error level that can be passed
          back to the calling application, in the range 0 to 255 inclusive. Batch files may perform on the
          result through the IF [NOT] ERRORLEVEL batch command.
          If the parameters passed to WINMAIN are not needed by the application itself, the PBMAIN
          function may be used in position of WINMAIN.
          Restrictions: Pointers may not be passed BYREF, so the lpszCmdLine parameter of WINMAIN
          must be affirmed to be passed BYVAL.


                 Example:
          #COMPILE  EXE
          FUNCTION  WINMAIN(BYVAL  hInst???,  BYVAL  hPrevInst???,  BYVAL  pCmdLine  AS
          WSTRINGZ  PTR,  BYVAL  nCmdShow&)  AS  LONG
              ‘  more  code  here
              FUNCTION  =  1
          END  FUNCTION





              Task  Illustrate the parameters hPrevInst and lpszCmdLine..

          Self Assessment

          Fill in the blanks:
          3.   .........................  is a user-defined  function called  by Windows to start execution of an
               application.
          4.   The ......................... value allocated to WINMAIN is optional, but by convention, the return
               value is derived from the wParam& parameter of a %WM_QUIT message.




                                           LOVELY PROFESSIONAL UNIVERSITY                                   33
   34   35   36   37   38   39   40   41   42   43   44