flat assembler
Message board for the users of flat assembler.

Index > Windows > Problem with GTK

Author
Thread Post new topic Reply to topic
mDrinky



Joined: 01 Jul 2012
Posts: 2
mDrinky
I have a problem with GTK ... I have a button, and pressing the event will run fine but then closes my program and not know why is that evil ago?

Code:
format PE GUI 4.0
entry main

include 'win32a.inc'

section '.data' data readable writeable
     hWindow                  dd ?
     Frame                    dd ?
     hBtnHi                   dd ?

     TitleWindow              db 'Mi primer GTK',0
     destroy                  db 'destroy',0
     BtnHi                    db 'Hola',0
     clicked                  db 'clicked',0

     ; MessageBox
     hBox    dd ?
     Text    db 'Mensajito',0
     Info    db 'Information',0

section '.code' code readable executable
main:
     invoke gtk_init,0,0
     invoke gtk_window_new,0
     mov [hWindow],eax
     invoke gtk_widget_show,[hWindow]

     invoke gtk_window_set_title,[hWindow],TitleWindow

     invoke gtk_fixed_new
     mov [Frame],eax
     invoke gtk_container_add,[hWindow],[Frame]

     invoke gtk_button_new_with_label,BtnHi
     mov [hBtnHi],eax
     invoke gtk_widget_set_size_request,eax,80,35
     invoke gtk_fixed_put,[Frame],[hBtnHi],10,10

     invoke g_signal_connect_data,[hWindow],destroy,EventDestroy,0,0
     invoke g_signal_connect_data,[hBtnHi],clicked,MessageBox,0,0

     invoke gtk_widget_show_all,[hWindow]

     invoke gtk_main
     ret


     proc EventDestroy,widget, gdata
         invoke gtk_main_quit
     endp

     proc MessageBox,widget, gdata
          invoke gtk_message_dialog_new,[hWindow],2,3,1,Text
          mov [hBox],eax
          invoke gtk_window_set_title,eax,Info
          invoke gtk_dialog_run,[hBox]
          invoke gtk_widget_destroy,[hBox]
          ret
     endp

section '.idata' import data readable

        library libgtk,'libgtk-win32-2.0-0.dll',\
                libobject,'libgobject-2.0-0.dll'

        import libgtk,\
               gtk_widget_show, 'gtk_widget_show',\
               gtk_init, 'gtk_init',\
               gtk_window_new, 'gtk_window_new',\
               gtk_main, 'gtk_main',\
               gtk_window_set_title,'gtk_window_set_title',\
               gtk_main_quit,'gtk_main_quit',\
               gtk_fixed_new,'gtk_fixed_new',\
               gtk_container_add,'gtk_container_add',\
               gtk_button_new_with_label,'gtk_button_new_with_label',\
               gtk_widget_set_size_request,'gtk_widget_set_size_request',\
               gtk_fixed_put,'gtk_fixed_put',\
               gtk_widget_show_all,'gtk_widget_show_all',\
               gtk_message_dialog_new,'gtk_message_dialog_new',\
               gtk_dialog_run,'gtk_dialog_run',\
               gtk_widget_destroy,'gtk_widget_destroy'

        import libobject,\
               g_signal_connect_data,'g_signal_connect_data'

                                                                
Post 01 Jul 2012, 15:53
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17270
Location: In your JS exploiting you and your system
revolution
Can we assume that GTK is a C library? If so then it is most likely that you need to use cinvoke to call the GTK functions.
Post 01 Jul 2012, 17:59
View user's profile Send private message Visit poster's website Reply with quote
mDrinky



Joined: 01 Jul 2012
Posts: 2
mDrinky
is working, thank you very much!
Post 01 Jul 2012, 21:54
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.