Menu

Question on using functions before WinMain

2002-11-21
2012-09-26
  • Nobody/Anonymous

    A quick question on C programming for Win32:

    No matter how many functions i put before WinMain(), they wont be executed, even if theyre named main(). The only thing i can do is leave them there and call them after WinMain().

    Am i right to think this way? Does it means that it probably is more logical to put the functions after WinMain() in a natural order?

    For example, if i want to check for the existance of a file, try to read its values, and set my mainwindow controls with this values, i was thinking of a function like that:

    int getdata() {
    FILE *dataFile;
    /*Some vars declared here*/
    if((dataFile=fopen("data.txt", "rw"))==NULL) {
    /* Do error stuff */
    return 1;
    }
    else {
    /*Read the file, and get the stuff to the vars*/
    return 0;
    }

    Using the example C code everybody has at %devcppdir%\templates\WinApp_C.txt, where would i paste my function?

    Any help would be great guys, im having a hard time here.

     
    • Nobody/Anonymous

      Hi,

      Intercept the WM_CREATEWINDOW message and put your startup code there. Or, if it is a dialog, intercept the WM_INITDIALOG message and do the same. L8tr.

      Kip

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.