Re: win32 port



Here's the WinMain that I've been using. I don't do much windows stuff
but it seems to be enough to get started with.

int _stdcall
WinMain (struct HINSTANCE__ *hInstance, 
	 struct HINSTANCE__ *hPrevInstance, 
	 char *lpszCmdLine, 
	 int nCmdShow)
{
  return main (__argc, __argv);
}


On 04 Jul 2001 02:04:15 +0800, watchthinker wrote:
> But I use the same code as listed and got strange errors:
> 
> hello1.c(41) : error C2282: 'FAR' is followed by 'PASCAL' (missing ','?)
> hello1.c(68) : error C2059: syntax error : '}'
> 
> Source code is as below
> #include <gtk/gtk.h>
> 
> char *xargv[20];
> int argc;
> 
> void hello(GtkWidget *widget, gpointer *data)
> {
> 	g_print("Hello, world!");
> }
> 
> void destroy(GtkWidget *widget, gpointer *data)
> {
> 	gtk_main_quit();
> }
> 
> int main(int argc, char *argv[])
> {
> 	GtkWidget *window;
> 	GtkWidget *button;
> 
> 	gtk_init(&argc, &argv);
> 	window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
> 
> 	gtk_signal_connect(GTK_OBJECT(window), "destroy", GTK_SIGNAL_FUNC(destroy), NULL);
> 	gtk_container_border_width(GTK_CONTAINER(window), 10);
> 
> 	button=gtk_button_new_with_label("Hello, world!");
> 	gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(hello), NULL);
> 	
> 	gtk_signal_connect_object(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(window));
> 	gtk_container_add(GTK_CONTAINER(window), button);
> 
> 	gtk_widget_show(button);
> 	gtk_widget_show(window);
> 
> 	gtk_main();	
> 	return 0;
> }
> 
> int FAR PASCAL WinMain(HINSTANCE hInst,HINSTANCE hPreInst, LPSTR lpszCmdLine, int nCmdShow)
>  {
>          int tmp;
>          
>          /* temporary */
>          if (getenv("WINMODE") != (char *)0) {
>                  if (strncmpi("WIN32",getenv("WINMODE"),5) == 0)
>                          winmode = WINMODE_WIN32;
>          }
>          switch(winmode) {
>  # ifndef WIN32S
>                  case WINMODE_TTY:
>                          strcpy(winstyle,"tty");
>                          tmp = AllocConsole();
>                          if (tmp) HaveConsole = 1;
>                          break;
>  # endif
> 
>                  case WINMODE_WIN32:
>                          strcpy(winstyle,"win32");
>                          break;
>                  default:
>                          strcpy(winstyle,DEFAULT_WINDOW_SYS);
>                          break;
>          }
>          choose_windows(winstyle);
>          return main(argc, xargv);
> }






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