User Tools

Site Tools


This is an old revision of the document!

A PCRE internal error occured. This might be caused by a faulty plugin

=====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:\\ * PROC_pushbutton * PROC_checkbox * PROC_radiobutton * PROC_editbox * PROC_static * PROC_listbox * PROC_combobox * PROC_dlgitem * 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):\\ \\ INSTALL @lib$+"WINLIB2" REM Acquire handle to BBCWIN.EXE or BBCWDEM.EXE: SYS "GetModuleHandle", 0 TO hmod% REM Locate specific dialog box resource: SYS "FindResource", hmod%, "CustomizeDlg", 5 TO hres% REM Load dialogue template into memory: SYS "LoadResource", hmod%, hres% TO hload% SYS "LockResource", hload% TO hmem% REM Find size of template: SYS "SizeofResource", hmod%, hres% TO rsize% dlg% = FN_newdialog("",0,0,0,0,0,rsize%+16) REM Copy dialogue template into dlg% array: SYS "RtlMoveMemory", dlg%+16, hmem%, rsize% REM Display dialogue box: dlg%?19 OR= &10 : REM Add WS_VISIBLE style 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:\\ SYS "LoadLibrary", "EXAMPLE.DLL" TO hmod% You can embed one or more resources in your own compiled executable as follows:\\ - Create the resource in 'Resource Compiler' (**.RC**) format. - 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**. \\ 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:\\ REM!Exefile @dir$+"myprog.exe",encrypt REM!Resource @dir$+"mydialog.res" Then you can access the resource from the 'real' program as follows:\\ SYS "LoadLibrary", @dir$+"myprog.exe" TO hmod% When you eventually compile your program, containing the resources in its EXE file, this will still work.

This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information
creating_20a_20dialogue_20box_20from_20a_20resource.1522502352.txt.gz · Last modified: 2018/03/31 14:19 by