Oxygen Basic
Programming => Example Code => Topic started by: Arnold on May 15, 2016, 12:57:32 PM
-
Hi Charles,
this was a lot of experimenting. And I am still not sure if everything works correctly.
I tried to use the routines of DialogFindReplace.inc in examples/WinGui as much as possible and apply them in Find_Replace.inc. Working through the example FindReplace.o2bas I had to add some modifications. Currently the resulting demo is only tested with my Windows Vista.
Maybe you will find some items in Find_Replace.inc which could be improved / corrected? Unfortunately there is not much reading material of this topic in Internet.
Roland
.
-
Hello,
this is another example of a Find and Replace Dialog. For this example I used a resource dll FRDll.dll for menu items, application icon and accelerators which is much easier to handle than to create them during Runtime.
I also used a project file for the latest Oxide. I added a HowToBuild.txt which should help to use the .proj file.
Are there any ideas how to build the .proj file efficiently from scratch?
Roland
.
-
Maybe it is better to split this project into two .proj files. I tried this for the dll:
FRDll.proj:
$project [C:\FindAndReplace4\FRDll.proj]
$files
<[FRDll.o2bas]> 000001 [C:\FindAndReplace4\FRDll.o2bas]
$main [C:\FindAndReplace4\FRDll.o2bas]
$binary [C:\FindAndReplace4\FRDll]
$command Compile .rc and link to dll
[
:: get path of Oxygenbasic
:: -------------------------
set o2hdir=c:\OxygenBasic
@echo off
set ResName=FR
set FileName=%ResName%Dll
set RC_compile=%o2hDir%\tools\GoRC.exe
set linkRes=%o2hDir%\tools\LinkRes2exe.exe
:: delete obj, res
::----------------
echo deleting obj, res FileNames
if exist %ResName%.obj del %ResName%.obj
if exist %ResName%.res del %ResName%.res
if exist %ResName%.rc %RC_compile% %ResName%.rc
if exist %ResName%.res %linkRes% %ResName%.res %FileName%.dll
pause
]
FRDll.o2bas would simply be:
After "Set Compile to Dll" and "Compile Independent Binary32" I can use ProjectUtil->Compile .rc and link to dll.
FindAndReplace4.proj would then be:
$project [C:\FindAndReplace4\FindAndReplace4.proj]
$files
<[oxygen.cfg]> 00001 [C:\FindAndReplace4\oxygen.cfg]
<[Find_Replace.inc]> 00001 [C:\FindAndReplace4\Find_Replace.inc]
<[FindandReplace4.o2bas]> 000001 [C:\FindAndReplace4\FindandReplace4.o2bas]
$main [C:\FindAndReplace4\FindandReplace4.o2bas]
$binary [C:\FindAndReplace4\FindandReplace4]
$command Run Executable
[
FindAndReplace4.exe
]
Perhaps there are some more alternatives?
-
Hello,
as a last exercise I created FindAndReplace as an excutable with resources in the exe file. For this project I created a subfolder \OxygenBasic\Projects\FindAndReplace. The latest Oxide is used.
To create the exe these steps are necessary:
Open Oxide, drag and drop FindAndReplace5.proj to the left panel. Double-Click on <[FindAndReplace5.o2bas].
Select Compile->Independent Binary32
Select ProjectUtil>Compile .rc and link to exe
Select ProjectUtil>Run Executable (in batch mode) or open FindAndReplace.exe directly in the directory.
BTW: The find / replace dialogs should be displayed in the native language of the OS if my assumptions are correct.
This application is derived from FindAndReplace4 where I used and extended a resource dll. I only needed three places in the .o2bas file to link the .rc file directly to the exe:
sys hResources = GetModuleHandle null
/*
sys hResources = loadlibrary "FRDll.dll"
if not hResources then
print "Error: FRDll.dll not found!"
end if
*/
For the WndClass wc structure:
...
wc.lpszMenuName = IDR_Mainmenu 'null
...
and last but least:
hwnd = CreateWindowEx 0,wc.lpszClassName,"Find and FindReplace",WS_OVERLAPPEDWINDOW,
Wtx,Wty,Wwd,Wht,
0,
null, 'LoadMenu(hResources, IDR_MAINMENU),
inst,0
So it should be rather easy to use either a resource dll or link resources directly to an exe file.
Roland
.