Results 1 to 4 of 4

Thread: Overloading WinMain while using MFC

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2001
    Location
    UK, Bristol
    Posts
    2

    Overloading WinMain while using MFC

    The program I am trying to write will be started twice, the first time with a "-R", the next without. In WinMain, I need to trap the "registration" call to the program, and exit with a Task Id.

    I have created the project with the MFC App Wizard, so how would I now override the WinMain function to test the Command Line Parameters?

    All help appreciated.

    Thanks
    I'm going bald ...
    Its self-inflicted ...
    I'm tearing my hair out!!!!

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    You can't override a already defined function.
    I'd say put your stuff in CMyApp::InitInstance() and exit after you processed it - this way, no window is created.
    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
    Aug 2001
    Location
    UK, Bristol
    Posts
    2
    Thanks for that. Unfortunately, the Framework doesn't seem to pass the commandline argument out of WinMain, and I need to parse that to determine which action to take.

    If the project wasn't using the communal WinMain I would edit the existing routine to add the additional code.

    Development has not progressed so far that I couldn't scrap what I have done and start again, but my experience with VC++ goes as far as the App Wizards and the Class Wizard - hence the reason I started with the MFC App Wizard Exe. If you could offer any further suggestions they woud be most appreciated.

    Thanks,

    Nick
    I'm going bald ...
    Its self-inflicted ...
    I'm tearing my hair out!!!!

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Your CWinApp object (the class of which InitInstance is a member) has a member named m_lpCommandLine. This is the command line.
    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.

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