Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: Need Help on making Window creating class

  1. #11
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,817
    Rep Power
    10
    Problem 1:
    it seems you have used MODAL windows. Modal Windows do not return control to main application until they are closed.
    You need to have modeless windows each with its window message plus a a global message pump

    Problem 2:
    not sure, maybe you are passing over the quit command from last window to main window.
    Also you need to keep track how many windows are still there and close only when needed.

    I still do not understand under which programming language are you developing
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  2. #12
    Member
    Join Date
    Aug 2015
    Location
    Keralam, India
    Posts
    121
    Rep Power
    22
    @Eros,
    Thanks for the reply. I will sure check about MODAL windows.
    Anyway, i have managed to fix the window closing issue. I just create a Global variabale in my module and keep the First window's (Main WIndow) handle on it. Besides that, i wrote an extra function in this module to create child windows for this main window. So in WndProc, i can handle WM_DESTROY msg with the window handle of MainWindow.

    I am coding this in FreeBasic. One thing i forgot to mention. I got a chance to learn a lot about win api in Frederick J Harris's tutorial on PowerBasic forum. Its really a wealth of information. In that tutorial, he wrote about how .Net handle the WndProc function with so many handler functions like OnClick, OnPaint, OnLoad etc.

  3. #13
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,817
    Rep Power
    10
    Eheh
    There will be great new features in thinBasic too under that aspect.

    The following is a thinBasic script working under the next thinBasic 1.10.5 I will release hopefully shortly.
    Every window or control will have the possibility to have an optional NAME
    And using that name plus the name of the event, you will be able to handle most of the events with easy function names.
    All into an interpreted source code script.

    USES "UI"
    uses "console"
    uses "Registry"
    
    
    '---Define a button ID
    begin ControlID
      %ButtonClose
      %ButtonSearch
      %lblFind
      %txtFind
      %lblReplace
      %txtReplace
    end ControlID
    
    
    
    
    DIALOG New Pixels, Name MyWindow, 0, "Dialog to show automatic events handling",-1,-1, 640, 480,
                                       %WS_DLGFRAME | %DS_CENTER | %WS_CAPTION | %WS_SYSMENU | %WS_OVERLAPPEDWINDOW
    
    
    CONTROL ADD Label   Name lblFind    , MyWindow.Handle, %lblFind     , "Find"    ,  10,  15, 350, 20, %SS_NOTIFY
    CONTROL ADD Textbox Name txtFind    , MyWindow.Handle, %txtFind     , ""        ,  10,  30, 350, 25, %ES_AUTOHSCROLL | %ES_LEFT | %WS_BORDER | %WS_TABSTOP
    
    
    CONTROL ADD Label   Name lblReplace , MyWindow.Handle, %lblReplace  , "Replace" ,  10,  55, 350, 20, %SS_NOTIFY
    CONTROL ADD Textbox Name txtReplace , MyWindow.Handle, %txtReplace  , ""        ,  10,  70, 350, 25, %ES_AUTOHSCROLL | %ES_LEFT | %WS_BORDER | %WS_TABSTOP
    
    
    
    
    CONTROL ADD BUTTON  Name btnSearch  , MyWindow.Handle, %ButtonSearch, "Search"  , 480,  10, 150, 25, %BS_NOTIFY | %BS_CENTER | %BS_VCENTER | %WS_TABSTOP
    CONTROL ADD BUTTON  Name btnCloseMe , MyWindow.Handle, %ButtonClose , "Close"   , 480,  40, 150, 25, %BS_NOTIFY | %BS_CENTER | %BS_VCENTER | %WS_TABSTOP
    
    
    
    
    
    
    DIALOG SHOW MODAL MyWindow.Handle
    
    
    
    
    '------------------------------------------------
    ' Callback function used to handle dialog events 
    ' not handled by specific event functions
    '------------------------------------------------
    CallBack Function MyWindow_OnCallBack() As Long
    '------------------------------------------------
    
    
      'printl Timer, Function_Name, CBMSG, MyWindow.Name & ": message not handled by specific event function"
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function MyWindow_OnInit() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
    
    
      '---Limits window minimum size
      DIALOG SET MINSIZE CBHNDL, 550, 220
       
      control set Resize CBHNDL, %ButtonSearch, 0, 1, 0, 0
      control set Resize CBHNDL, %ButtonClose , 0, 1, 0, 0
    
    
      txtFind.Text    = "TextToFind"
      txtReplace.Text = "TextToReplace"
      btnCloseMe.Text = "Close Me"
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function MyWindow_OnSize() As Long
    '------------------------------------------------
      
      printl Timer, Function_Name, MyWindow.X, MyWindow.Y, MyWindow.W, MyWindow.H
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function MyWindow_OnMove() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name, MyWindow.X, MyWindow.Y, MyWindow.W, MyWindow.H
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function MyWindow_OnMoving() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function MyWindow_OnMouseMove() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function MyWindow_OnNCHITTEST() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function MyWindow_OnSETCURSOR() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function MyWindow_OnLBUTTONDOWN() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function MyWindow_OnLBUTTONUP() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function MyWindow_OnLBUTTONDBLCLK() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function MyWindow_OnNCMOUSEMOVE() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function MyWindow_OnNCMOUSELEAVE() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function MyWindow_OnCommand() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
      
    End Function
    
    
    '------------------------------------------------
    CallBack Function MyWindow_OnClose() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function MyWindow_OnSHOWWINDOW() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function MyWindow_OnDestroy() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name
      PrintL "Window just destroyed. Press a key to end" in %CCOLOR_FLIGHTRED
      WaitKey
    
    
    End Function
    
    
    
    
    
    
    '------------------------------------------------------------------------------
    ' BUTTON EVENT
    '------------------------------------------------------------------------------
    
    
    '------------------------------------------------
    CallBack Function btnCloseMe_OnClick() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name, btnCloseMe.Name
      DIALOG End CBHNDL
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function btnCloseMe_OnSetFocus() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name, btnCloseMe.Name
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function btnCloseMe_OnKillFocus() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name, btnCloseMe.Name
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function btnSearch_OnClick() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name, btnSearch.Name, "Search clicked, something new should happen :)"
    
    
    End Function
    
    
    '------------------------------------------------------------------------------
    ' LABEL EVENT
    '------------------------------------------------------------------------------
    
    
    '------------------------------------------------
    CallBack Function lblFind_OnClick() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name, lblFind.Name
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function lblFind_OnDblClk() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name, lblFind.Name
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function lblFind_OnDisable() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name, lblFind.Name
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function lblFind_OnEnable() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name, lblFind.Name
    
    
    End Function
    
    
    
    
    '------------------------------------------------------------------------------
    ' TEXTBOX EVENT
    '------------------------------------------------------------------------------
    
    
    '------------------------------------------------
    CallBack Function txtFind_OnCallback() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name, CBCTLMSG, txtFind.Name
      Function = %TRUE
    
    
    End Function
    
    
    
    
    '------------------------------------------------
    CallBack Function txtFind_OnChange() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name, "text changed in control ", txtFind.Name
      printl txtFind.Text in %CCOLOR_FLIGHTCYAN
    
    
      Function = %TRUE
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function txtFind_OnUpdate() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name, txtFind.Name
      Function = %TRUE
      
    End Function
    
    
    '------------------------------------------------
    CallBack Function txtFind_OnSetFocus() As Long
    '------------------------------------------------
      txtFind.backcolor = %RGB_THISTLE
      printl Timer, Function_Name, txtFind.Name
      
    End Function
    
    
    '------------------------------------------------
    CallBack Function txtFind_OnKillFocus() As Long
    '------------------------------------------------
    
    
      txtFind.backcolor = %RGB_WHITE
      printl Timer, Function_Name, txtFind.Name
      
    End Function
    
    
    '------------------------------------------------
    CallBack Function txtReplace_OnChange() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name, "text changed in control ", txtReplace.Name
      printl txtReplace.Text in %CCOLOR_FLIGHTCYAN
      Function = %TRUE
    
    
    End Function
    
    
    '------------------------------------------------
    CallBack Function txtReplace_OnUpdate() As Long
    '------------------------------------------------
    
    
      printl Timer, Function_Name, txtReplace.Name
      Function = %TRUE
      
    End Function
    
    
    '------------------------------------------------
    CallBack Function txtReplace_OnSetFocus() As Long
    '------------------------------------------------
    
    
      txtReplace.backcolor = %RGB_AQUAMARINE
      printl Timer, Function_Name, txtReplace.Name
      
    End Function
    
    
    '------------------------------------------------
    CallBack Function txtReplace_OnKillFocus() As Long
    '------------------------------------------------
    
    
      txtReplace.backcolor = %RGB_WHITE
      printl Timer, Function_Name, txtReplace.Name
      
    End Function
    
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  4. #14
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    55
    Posts
    1,554
    Rep Power
    174
    Reads good so far

    Were it possible to make the event-callback-functions to receive the user-property of the controls?

    For example I have some images to display and I give all image-controls the same name and every image-control an index-number -
    could be stored in the user-slots
    (Control Set User...)-
    Now assumed one of the images gets clicked and within the events callback I want to know the images index:

    Callback Function myimage_OnLeftButtonDown(Optional Userdata(4) As Long) As Long
    
    Or is there another way to retrieve the desired data stored at the control?
    I think there are missing some Forum-sections as beta-testing and support

Page 2 of 2 FirstFirst 12

Similar Threads

  1. MyClass & MyClassCOM - simple demo of creating module class
    By Petr Schreiber in forum Module Classes
    Replies: 3
    Last Post: 21-05-2013, 00:09
  2. creating my own class
    By ReneMiner in forum thinBasic General
    Replies: 4
    Last Post: 17-11-2012, 20:07
  3. making .ini files
    By sandyrepope in forum INI
    Replies: 3
    Last Post: 20-08-2007, 10:01
  4. making programs pretty
    By sandyrepope in forum Console
    Replies: 9
    Last Post: 13-05-2007, 20:55
  5. making help files for our programs
    By sandyrepope in forum thinBasic General
    Replies: 1
    Last Post: 20-02-2007, 20:18

Members who have read this thread: 0

There are no members to list at the moment.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •