User Tools

Site Tools


creating_20a_20dialogue_20box_20from_20a_20resource

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
creating_20a_20dialogue_20box_20from_20a_20resource [2018/03/31 13:19] – external edit 127.0.0.1creating_20a_20dialogue_20box_20from_20a_20resource [2024/01/05 00:22] (current) – external edit 127.0.0.1
Line 1: Line 1:
 =====Creating a dialogue box from a resource===== =====Creating a dialogue box from a resource=====
  
-//by Richard Russell, May 2006, revised April 2012//\\ \\  The normal method of creating a dialogue box in BBC BASIC for Windows is to call the procedures in the **WINLIB2** library:\\ +//by Richard Russell, May 2006, revised April 2012//\\ \\  The normal method of creating a dialogue box in BBC BASIC for Windows is to call the procedures in the **WINLIB2** library: 
  
   * PROC_pushbutton   * PROC_pushbutton
Line 12: Line 12:
   * PROC_dlgitem   * PROC_dlgitem
   * PROC_dlgctrl   * PROC_dlgctrl
-\\  However there may be circumstances when the dialogue box has already been designed and its template is contained as a //resource// within a DLL or EXE file. In that case you can create the dialogue box in your program using the resource data. The code example below creates a dialogue box from the resource data for BB4W's **Customize** dialogue (in BBCWIN.EXE or BBCWDEM.EXE):\\ \\ + 
 +However there may be circumstances when the dialogue box has already been designed and its template is contained as a //resource// within a DLL or EXE file. In that case you can create the dialogue box in your program using the resource data. The code example below creates a dialogue box from the resource data for BB4W's **Customize** dialogue (in BBCWIN.EXE or BBCWDEM.EXE): 
 + 
 +<code bb4w>
         INSTALL @lib$+"WINLIB2"         INSTALL @lib$+"WINLIB2"
  
Line 31: Line 34:
         dlg%?19 OR= &10 : REM Add WS_VISIBLE style         dlg%?19 OR= &10 : REM Add WS_VISIBLE style
         PROC_showdialog(dlg%)         PROC_showdialog(dlg%)
-Naturally this code will only run within the **BB4W IDE**, because if compiled to an executable file the dialogue box resource data will not be present.\\ \\  To load the dialogue box resource data from a different file (for example a DLL) then replace the call to "GetModuleHandle" with a call to "LoadLibrary" as follows:\\ +</code> 
 + 
 +Naturally this code will only run within the **BB4W IDE**, because if compiled to an executable file the dialogue box resource data will not be present.\\ \\  To load the dialogue box resource data from a different file (for example a DLL) then replace the call to "GetModuleHandle" with a call to "LoadLibrary" as follows: 
 + 
 +<code bb4w>
         SYS "LoadLibrary", "EXAMPLE.DLL" TO hmod%         SYS "LoadLibrary", "EXAMPLE.DLL" TO hmod%
 +</code>
 +
 You can embed one or more resources in your own compiled executable as follows:\\  You can embed one or more resources in your own compiled executable as follows:\\ 
  
Line 38: Line 47:
   - Compile the resource from a **.RC** file to a **.RES** file using a Resource Compiler.   - Compile the resource from a **.RC** file to a **.RES** file using a Resource Compiler.
   - Specify that the resource should be embedded in your program using **REM!Resource**.   - Specify that the resource should be embedded in your program using **REM!Resource**.
-\\  To enable you to develop and test your program in the BB4W IDE you can initially create a 'dummy' executable, by compiling a program containing only the "REM!Resource" directive:\\ + 
 +To enable you to develop and test your program in the BB4W IDE you can initially create a 'dummy' executable, by compiling a program containing only the "REM!Resource" directive: 
 + 
 +<code bb4w>
         REM!Exefile @dir$+"myprog.exe",encrypt         REM!Exefile @dir$+"myprog.exe",encrypt
         REM!Resource @dir$+"mydialog.res"         REM!Resource @dir$+"mydialog.res"
-Then you can access the resource from the 'real' program as follows:\\ +</code> 
 + 
 +Then you can access the resource from the 'real' program as follows: 
 + 
 +<code bb4w>
         SYS "LoadLibrary", @dir$+"myprog.exe" TO hmod%         SYS "LoadLibrary", @dir$+"myprog.exe" TO hmod%
 +</code>
 +
 When you eventually compile your program, containing the resources in its EXE file, this will still work. When you eventually compile your program, containing the resources in its EXE file, this will still work.
creating_20a_20dialogue_20box_20from_20a_20resource.1522502352.txt.gz · Last modified: 2024/01/05 00:18 (external edit)