Re: gtk win32 app without console





F. Kater ha scritto lo scorso 07/07/04 22.38:
Hi,

I hope you don't find this issue too off topic here! :-)

I am developing a gtk win32 app. As IDE I use ms visual studio c++ 6.0.
This projects was created once as an "empty console application" to be
most indipendant from ms -- however, now I would like to turn off the
console running in the background of my app. I don't use any ms
dependant stuff.

Is there an easy to do that -- port main(...) to WinMain(...) etc?

I usually use a quite dirty trick; issuing the command

editbin /subsystem:windows your-app.exe

you can modify the stub of your application executable and the windows
console will not appear at launch-time; nevertheless, you should have
warning or error messages from glib or gtk or other libraries, which
normally use g_warnings or similar stuff. In this case you may choose to
 intercept those messages. In following code snippet there is an
example of how to catch warning messages coming from glib (in my case it
was a "g_io_win32_set_flags () not implemented" generated by a call to
g_io_channel_shutdown):

void your_logger (const gchar    * log_domain,
                  GLogLevelFlags   log_level,
                  const gchar    * message,
                  gpointer         user_data) {

    /* Do here what you want of your warning messages
     */
}

int main (int argc, char *argv[]) {
    GtkWidget * winMain;

    gtk_set_locale ();
    gtk_init (&argc, &argv);

    /* Sets the default log handler for warning messages
     * generated from GLib
     */
    g_log_set_handler ("GLib",
                       G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL |
G_LOG_FLAG_RECURSION,
                       your_logger,
                       NULL);

    winMain = create_winMain ();
    gtk_widget_show (winMain);

    gtk_main ();
    return (0);
}

HTH,
Carlo

--
/*
 *      Imagination is more important
 *      than knowledge.
 *                      A. Einstein
 */





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]