Author Topic: O2RadAsm  (Read 487 times)

0 Members and 1 Guest are viewing this topic.

jcfuller

  • Full Member
  • ***
  • Posts: 143
O2RadAsm
« on: March 04, 2018, 02:06:24 PM »
Here is an ide based on RadAsm3, for creation of stand-alone exe and dll files.

I have used resource dialogs going all the way back to Windows 3. For the apps I was creating (mainly data input screens) it worked fine then and it still works fine today. Resource dialogs automatically handle non-default dpi settings quite nicely . Usually your text will be a bit fuzzy but with the correct manifest entries this is alleviated.

It also makes porting PowerBASIC DDT display code much easier because you can use the same coordinates.
If you do not want to use resource dialogs in your app you can use my dlg2src utility to create OxygenBasic SDK source.

One of the Projects is a port of KarenZ's demo.

James





Aurel

  • Sr. Member
  • ****
  • Posts: 252
Re: O2RadAsm
« Reply #1 on: March 04, 2018, 02:21:32 PM »
Hay James
heh interesting Ketil'o editor ..right?
I found Karen1 o2bas ..but i cannot figured how compile this program with
this scary editor...?
and there is no visual designer just resource editor but all in all very good!
I must investigate this little bit more  :)

KarenZ

  • Newbie
  • *
  • Posts: 44
Re: O2RadAsm
« Reply #2 on: March 05, 2018, 07:42:03 AM »
Thanks James
Pretty good looking editor however not able to compile some original O2bas programs?
When I compile them it says "error "
Perhaps a short lesson or 2 could help us beginners to get started.

Regards
Karen

jcfuller

  • Full Member
  • ***
  • Posts: 143
Re: O2RadAsm
« Reply #3 on: March 05, 2018, 08:09:50 AM »
Karen,
  Gladly If:
You have read the readme file.
You have read the o2RadAsm.htm file
  This is pretty complete I think, and I would just be repeating what is in there.

Does the code compile using other means.

I really am more than willing to help but I need more than it give's error.
Show me the source where you get an error.

I will see what I can do for a tutorial.
James

Aurel

  • Sr. Member
  • ****
  • Posts: 252
Re: O2RadAsm
« Reply #4 on: March 05, 2018, 09:40:08 AM »
Sorry James
 i also cannot compile nothing even u add AurelEdit there.
is there a way to use gxo2.exe directly not over bxo2...
and what is bxo2 ?

Aurel

  • Sr. Member
  • ****
  • Posts: 252
Re: O2RadAsm
« Reply #5 on: March 05, 2018, 09:47:50 AM »
Karen
You you have error in your code under typedef structure
your UDT -> RECT is not defined before !

so you need something like this :
Type RECT
 Left   as Long
 Top    as Long
 Right  as Long
 Bottom as Long
End Type


Anyway what is this program?

Aurel

  • Sr. Member
  • ****
  • Posts: 252
Re: O2RadAsm
« Reply #6 on: March 05, 2018, 09:51:56 AM »
Uooh..
CreateSolidBrush not defined too...
line 102...

Declare Function CreateSolidBrush Lib "gdi32.dll" (ByVal crColor As Long) As Long

..and GetMessage(&Msg, NULL, 0, 0) -> not defined !

Aurel

  • Sr. Member
  • ****
  • Posts: 252
Re: O2RadAsm
« Reply #7 on: March 05, 2018, 10:15:16 AM »
Karen
u use on some places where is needed UDT - RECT type
u use adress sign & ,but there is no need for that just use UDT variable
without pointer sign like rcb and not  &rcb

This PB dialogs drive me crazy...so whole DDT is based on Dialogs not Windows ,,right?

i fix some things but i don't add Dialog USES or INCLUDE:

Code: [Select]
'include
include "awinh.inc"
! CreateDialogParam lib "user32.dll" alias "CreateDialogParamA" (sys hInstance, lpTemplate, hWndParent, lpDialogFunc, lParamInit) as sys
! IsDialogMessage lib "user32.dll" alias"IsDialogMessageA" (sys hDlg, lpMsg) as bool
! GetDlgItem lib "user32.dll" alias "GetDlgItem"(sys,int) as sys
! GetSysColor lib "user32.dll" alias "GetSysColor"(int) as dword
! CreatePen lib "gdi32.dll" alias "CreatePen"(int,int,COLORREF)
! MapWindowPoints lib "user32.dll" alias "MapWindowPoints"(sys,sys,sys,unit)
! Rectangle lib "gdi32.dll" alias "Rectangle"(sys,int,int,int,int)As bool
! CreateSolidBrush Lib "gdi32.dll" (ByVal crColor As Long) As Long
%IDD_DLG1 = 1000
%IDC_SBR1 = 1001
%IDC_BTN1 = 1002
%IDC_STC1 = 1003
%IDC_EDT1 = 1004
'==============================================================================
int FlagExit
double resix
'==============================================================================
#define DT_TOP  0x00000000
#define DT_LEFT  0x00000000
#define DT_CENTER  0x00000001
#define DT_RIGHT  0x00000002
#define DT_VCENTER  0x00000004
#define DT_BOTTOM  0x00000008
#define DT_WORDBREAK  0x00000010
#define DT_SINGLELINE  0x00000020
#define DT_EXPANDTABS  0x00000040
#define DT_TABSTOP  0x00000080
#define DT_NOCLIP  0x00000100
#define DT_EXTERNALLEADING  0x00000200
#define DT_CALCRECT  0x00000400
#define DT_NOPREFIX  0x00000800
#define DT_INTERNAL  0x00001000
'==============================================================================

'indexbase 0
typedef DWORD COLORREF
% COLOR_3DFACE = 15
% SBT_OWNERDRAW = 0x1000
% SB_SETTEXT = WM_USER+1
% WM_DRAWITEM  = 0x002B
% NULL_BRUSH  = 5
% PS_SOLID  = 0
% RGB_AZURE = 0xFFFFF0
% RGB_BLUE = 0xFF0000
% RGB_MAGENTA = 0xFF00FF

macro RGB(r,g,b) {r+(g<<8)+(b<<16)}
'==============================================================================
% SB_SETPARTS (WM_USER+4)

Type RECT
 Left   as Long
 Top    as Long
 Right  as Long
 Bottom as Long
End Type

typedef struct tagDRAWITEMSTRUCT {
  UINT      CtlType;
  UINT      CtlID;
  UINT      itemID;
  UINT      itemAction;
  UINT      itemState;
  sys      hwndItem;
  sys       hDC;
  RECT      rcItem; 'RECT not defined
  sys itemData;
} DRAWITEMSTRUCT
Sub SetSbParts(byval sys sbar,double* sParts)
int i,j,k
RECT rc
string t
indexbase 0
dim As int parts[16]

GetClientRect(sbar,rc)
j = 0
i = 0

k = rc.right * sParts[0]
If k = 0 Then
Exit Sub
End If
parts[i] = k

Do
i++
j++
If sParts[j] = 0 Then
Exit Do
End If
k = k + (rc.right * sParts[j])
parts[i] = k
End do

SendMessage(sbar,SB_SETPARTS,i,&parts)
End Sub
'==============================================================================
Function SetColor(byval TxtColr As COLORREF,byval BkColr As COLORREF,byval hdc As sys) As sys
static sys ReUsableBrush
DeleteObject(ReusableBrush)
ReUsableBrush = CreateSolidBrush( BkColr )
SetTextColor( hdc, TxtColr )
SetBkColor( hdc, BkColr )
Function = ReUsableBrush
End Function
'==============================================================================
Sub dosomethin()
long i
double ix
For i = 1 To 100
ix = i + (ix+21)*2
Next i
Print " did some thing and then exit " + chr(13,10) + str(ix)
FlagExit = 1
resix = ix
End Sub
 
Function WinMain(sys hInst, prevInst, asciiz*cmdline, sys show) as sys
sys hDlg,bRet
MSG msg

hDlg = CreateDialogParam(hInst,IDD_DLG1,0,@DlgProc,0)
If hDlg = -1 Then
Print "hDlg = -1"
exit function
End If
While GetMessage(&Msg, NULL, 0, 0)
If not IsDialogMessage(hDlg, &Msg) Then
TranslateMessage(&Msg)
DispatchMessage(&Msg)
End If
Wend
End Function
'==============================================================================
Sub PaintDlgBorder(Byval hDlg As sys)
dword hdgBrush,hdgPen
RECT rcdg,rcsb,rcb
PAINTSTRUCT psdg
GetClientRect hDlg,rcdg
GetWindowRect(GetDlgItem(hDlg,IDC_SBR1),rcsb)
MapWindowPoints(0,hDlg,&rcsb,2)

GetWindowRect(GetDlgItem(hDlg,IDC_BTN1),rcb)
MapWindowPoints(0,hDlg,rcb,2)

BeginPaint hDlg,&psdg
Rectangle psdg.hdc,rcb.left-1,rcb.top-1,rcb.right+1,rcb.bottom+1
hdgPen = CreatePen(PS_SOLID,1,RGB_MAGENTA)
hdgPen = SelectObject(psdg.hdc,hdgPen)
hdgBrush = SelectObject(psdg.hdc,GetStockObject(NULL_BRUSH))
Rectangle psdg.hdc,rcdg.left,rcdg.top,rcdg.right,rcdg.bottom-(rcsb.bottom-rcsb.top)
SelectObject psdg.hdc,hdgBrush
DeleteObject SelectObject(psdg.hdc,hdgPen)
EndPaint hDlg,&psdg
End Sub
'==============================================================================
#define CBCTL LOWORD(wParam)
#define CBCTLMSG HIWORD(wParam)

Function DlgProc(byval hDlg As sys,byval uMsg As uint,byval wParam As sys,byval lParam AS sys) As sys callback

Select Case uMsg
Case WM_INITDIALOG
'indexbase 0
Dim As double SbParts()={.50,.50,0.0}
sys hSbar = GetDlgItem(hDlg,IDC_SBR1)
SetSbParts(hSbar,SbParts)
SendMessage(hSbar,SB_SETTEXT,0 OR SBT_OWNERDRAW,0)
SendMessage(hSBar,SB_SETTEXT,1 OR SBT_OWNERDRAW," Enter characters Only")
SendMessage(hSbar,SB_SETTEXT,0 OR SBT_OWNERDRAW,0)
Case WM_CLOSE
DestroyWindow(hDlg)
Case WM_DESTROY
PostQuitMessage(null)
Case WM_COMMAND
Select Case loword(wParam)
Case IDCANCEL
PostMessage hDlg,WM_CLOSE,0,0
Case IDC_BTN1
If CBCTLMSG = BN_CLICKED OR CBCTLMSG = 1 then
string sTextSb = "Some text was entered"
SetWindowText(GetDlgItem(hDlg,IDC_EDT1),strptr(sTextSb))
dosomethin()
If FlagExit = 1 Then
Sleep(1000)
SendMessage hDlg, WM_CLOSE,0,0
End If

End If
End Select
Case WM_CTLCOLORSTATIC
If lParam = GetDlgItem(hDlg,IDC_STC1) Then
return  SetColor(RGB(0,0,128),GetSysColor(COLOR_3DFACE),wParam)
End If
Case WM_DRAWITEM
Dim As sys hBrushS,hPenS
Dim As zstring* zpS
Dim As DRAWITEMSTRUCT* lpdis
If wParam = IDC_SBR1 Then
@lpdis = lParam
hBrushS = SelectObject(lpdis.hDc,GetStockObject(NULL_BRUSH))
' box color for the statusbar using a width of 2
hPenS = CreatePen(PS_SOLID,2,RGB(255,0,255))
hPenS = SelectObject(lpdis.hDc,hPenS)
SetColor(RGB_BLUE,RGB_AZURE,lpdis.hDc)
@zpS = lpdis.itemData
Dim ss As string
ss = zpS
DrawText lpdis.hdc,strptr(ss),Len(ss),lpdis.rcitem,DT_CENTER OR DT_SINGLELINE OR DT_VCENTER
Rectangle lpdis.hdc,lpdis.rcitem.left,lpdis.rcitem.top,lpdis.rcitem.right,lpdis.rcitem.bottom
SelectObject lpdis.hdc,hBrushS
DeleteObject SelectObject(lpdis.hdc,hPenS)
Function = 1
End If
Case WM_PAINT
PaintDlgBorder hDlg
End Select
Function = 0
End Function
'==============================================================================
'=========
'MAIN CODE
'=========

Dim cmdline as asciiz ptr, inst as sys
cmdline=GetCommandLine
inst=GetModuleHandle 0
'
'WINDOWS START
'=============
'
WinMain inst,0,cmdline,SW_NORMAL
end


jcfuller

  • Full Member
  • ***
  • Posts: 143
Re: O2RadAsm
« Reply #8 on: March 05, 2018, 10:41:30 AM »
Aurel,
  I believe your lack of understanding the help file is your major problem.

James

Aurel

  • Sr. Member
  • ****
  • Posts: 252
Re: O2RadAsm
« Reply #9 on: March 05, 2018, 11:09:38 AM »
James
Yeah maybe you have a right but why is so complex..
i understand that this editor is for few languages but using external exes to run main
compiler looks to me problematic.

Charles
I tryed to compile this freaky dialog app using Dialogs.inc  + fix some bugs inside same include
also included minWin.inc + generics.inc  .... geee neverending includes  :D
in fact oxygen compile this example but there is no executable or runing program ?
Also few other samples from WinDynDialogs are with errors like Richedit example?

here is code:

Code: [Select]
'include
$ filename "Karen1_01.exe"
include "Dialogs.inc"
include "awinh.inc"
! CreateDialogParam lib "user32.dll" alias "CreateDialogParamA" (sys hInstance, lpTemplate, hWndParent, lpDialogFunc, lParamInit) as sys
! IsDialogMessage lib "user32.dll" alias"IsDialogMessageA" (sys hDlg, lpMsg) as bool
! GetDlgItem lib "user32.dll" alias "GetDlgItem"(sys,int) as sys
! GetSysColor lib "user32.dll" alias "GetSysColor"(int) as dword
! CreatePen lib "gdi32.dll" alias "CreatePen"(int,int,COLORREF)
! MapWindowPoints lib "user32.dll" alias "MapWindowPoints"(sys,sys,sys,unit)
! Rectangle lib "gdi32.dll" alias "Rectangle"(sys,int,int,int,int)As bool
! CreateSolidBrush Lib "gdi32.dll" (ByVal crColor As Long) As Long

%IDD_DLG1 = 1000
%IDC_SBR1 = 1001
%IDC_BTN1 = 1002
%IDC_STC1 = 1003
%IDC_EDT1 = 1004
'==============================================================================
int FlagExit
double resix
'==============================================================================
#define DT_TOP  0x00000000
#define DT_LEFT  0x00000000
#define DT_CENTER  0x00000001
#define DT_RIGHT  0x00000002
#define DT_VCENTER  0x00000004
#define DT_BOTTOM  0x00000008
#define DT_WORDBREAK  0x00000010
#define DT_SINGLELINE  0x00000020
#define DT_EXPANDTABS  0x00000040
#define DT_TABSTOP  0x00000080
#define DT_NOCLIP  0x00000100
#define DT_EXTERNALLEADING  0x00000200
#define DT_CALCRECT  0x00000400
#define DT_NOPREFIX  0x00000800
#define DT_INTERNAL  0x00001000
'==============================================================================

'indexbase 0
typedef DWORD COLORREF
% COLOR_3DFACE = 15
% SBT_OWNERDRAW = 0x1000
% SB_SETTEXT = WM_USER+1
% WM_DRAWITEM  = 0x002B
% NULL_BRUSH  = 5
% PS_SOLID  = 0
% RGB_AZURE = 0xFFFFF0
% RGB_BLUE = 0xFF0000
% RGB_MAGENTA = 0xFF00FF

macro RGB(r,g,b) {r+(g<<8)+(b<<16)}
'==============================================================================
% SB_SETPARTS (WM_USER+4)

Type RECT
 Left   as Long
 Top    as Long
 Right  as Long
 Bottom as Long
End Type

typedef struct tagDRAWITEMSTRUCT {
  UINT      CtlType;
  UINT      CtlID;
  UINT      itemID;
  UINT      itemAction;
  UINT      itemState;
  sys      hwndItem;
  sys       hDC;
  RECT      rcItem; 'RECT not defined
  sys itemData;
} DRAWITEMSTRUCT
Sub SetSbParts(byval sys sbar,double* sParts)
int i,j,k
RECT rc
string t
indexbase 0
dim As int parts[16]

GetClientRect(sbar,rc)
j = 0
i = 0

k = rc.right * sParts[0]
If k = 0 Then
Exit Sub
End If
parts[i] = k

Do
i++
j++
If sParts[j] = 0 Then
Exit Do
End If
k = k + (rc.right * sParts[j])
parts[i] = k
End do

SendMessage(sbar,SB_SETPARTS,i,&parts)
End Sub
'==============================================================================
Function SetColor(byval TxtColr As COLORREF,byval BkColr As COLORREF,byval hdc As sys) As sys
static sys ReUsableBrush
DeleteObject(ReusableBrush)
ReUsableBrush = CreateSolidBrush( BkColr )
SetTextColor( hdc, TxtColr )
SetBkColor( hdc, BkColr )
Function = ReUsableBrush
End Function
'==============================================================================
Sub dosomethin()
long i
double ix
For i = 1 To 100
ix = i + (ix+21)*2
Next i
Print " did some thing and then exit " + chr(13,10) + str(ix)
FlagExit = 1
resix = ix
End Sub
 
Function WinMain(sys hInst, prevInst, asciiz*cmdline, sys show) as sys
sys hDlg,bRet
MSG msg

hDlg = CreateDialogParam(hInst,IDD_DLG1,0,@DlgProc,0)
If hDlg = -1 Then
Print "hDlg = -1"
exit function
End If
While GetMessage(&Msg, NULL, 0, 0)
If not IsDialogMessage(hDlg, &Msg) Then
TranslateMessage(&Msg)
DispatchMessage(&Msg)
End If
Wend
End Function
'==============================================================================
Sub PaintDlgBorder(Byval hDlg As sys)
dword hdgBrush,hdgPen
RECT rcdg,rcsb,rcb
PAINTSTRUCT psdg
GetClientRect hDlg,rcdg
GetWindowRect(GetDlgItem(hDlg,IDC_SBR1),rcsb)
MapWindowPoints(0,hDlg,&rcsb,2)

GetWindowRect(GetDlgItem(hDlg,IDC_BTN1),rcb)
MapWindowPoints(0,hDlg,rcb,2)

BeginPaint hDlg,&psdg
Rectangle psdg.hdc,rcb.left-1,rcb.top-1,rcb.right+1,rcb.bottom+1
hdgPen = CreatePen(PS_SOLID,1,RGB_MAGENTA)
hdgPen = SelectObject(psdg.hdc,hdgPen)
hdgBrush = SelectObject(psdg.hdc,GetStockObject(NULL_BRUSH))
Rectangle psdg.hdc,rcdg.left,rcdg.top,rcdg.right,rcdg.bottom-(rcsb.bottom-rcsb.top)
SelectObject psdg.hdc,hdgBrush
DeleteObject SelectObject(psdg.hdc,hdgPen)
EndPaint hDlg,&psdg
End Sub
'==============================================================================
#define CBCTL LOWORD(wParam)
#define CBCTLMSG HIWORD(wParam)

Function DlgProc(byval hDlg As sys,byval uMsg As uint,byval wParam As sys,byval lParam AS sys) As sys callback

Select Case uMsg
Case WM_INITDIALOG
'indexbase 0
Dim As double SbParts()={.50,.50,0.0}
sys hSbar = GetDlgItem(hDlg,IDC_SBR1)
SetSbParts(hSbar,SbParts)
SendMessage(hSbar,SB_SETTEXT,0 OR SBT_OWNERDRAW,0)
SendMessage(hSBar,SB_SETTEXT,1 OR SBT_OWNERDRAW," Enter characters Only")
SendMessage(hSbar,SB_SETTEXT,0 OR SBT_OWNERDRAW,0)
Case WM_CLOSE
DestroyWindow(hDlg)
Case WM_DESTROY
PostQuitMessage(null)
Case WM_COMMAND
Select Case loword(wParam)
Case IDCANCEL
PostMessage hDlg,WM_CLOSE,0,0
Case IDC_BTN1
If CBCTLMSG = BN_CLICKED OR CBCTLMSG = 1 then
string sTextSb = "Some text was entered"
SetWindowText(GetDlgItem(hDlg,IDC_EDT1),strptr(sTextSb))
dosomethin()
If FlagExit = 1 Then
Sleep(1000)
SendMessage hDlg, WM_CLOSE,0,0
End If

End If
End Select
Case WM_CTLCOLORSTATIC
If lParam = GetDlgItem(hDlg,IDC_STC1) Then
return  SetColor(RGB(0,0,128),GetSysColor(COLOR_3DFACE),wParam)
End If
Case WM_DRAWITEM
Dim As sys hBrushS,hPenS
Dim As zstring* zpS
Dim As DRAWITEMSTRUCT* lpdis
If wParam = IDC_SBR1 Then
@lpdis = lParam
hBrushS = SelectObject(lpdis.hDc,GetStockObject(NULL_BRUSH))
' box color for the statusbar using a width of 2
hPenS = CreatePen(PS_SOLID,2,RGB(255,0,255))
hPenS = SelectObject(lpdis.hDc,hPenS)
SetColor(RGB_BLUE,RGB_AZURE,lpdis.hDc)
@zpS = lpdis.itemData
Dim ss As string
ss = zpS
DrawText lpdis.hdc,strptr(ss),Len(ss),lpdis.rcitem,DT_CENTER OR DT_SINGLELINE OR DT_VCENTER
Rectangle lpdis.hdc,lpdis.rcitem.left,lpdis.rcitem.top,lpdis.rcitem.right,lpdis.rcitem.bottom
SelectObject lpdis.hdc,hBrushS
DeleteObject SelectObject(lpdis.hdc,hPenS)
Function = 1
End If
Case WM_PAINT
PaintDlgBorder hDlg
End Select
Function = 0
End Function
'==============================================================================
'=========
'MAIN CODE
'=========

Dim cmdline as string, inst as sys
cmdline = GetCommandLine ()
inst = GetModuleHandle 0
'
'WINDOWS START
'=============
'
WinMain inst,0,cmdline,SW_NORMAL
end


KarenZ

  • Newbie
  • *
  • Posts: 44
Re: O2RadAsm
« Reply #10 on: March 05, 2018, 01:07:49 PM »
Hi Aurel

Not sure where the RECT structure came from, probably it came from James who did a conversion of
the original PB program "DDT nice.bas" on PAINT.  Please see attachment file

Hi James
That Karen1_01.o2bas is quite complicated and must have taken some time ?  Thanks so much
Conversion from PB looks tough

Regards
Karen

KarenZ

  • Newbie
  • *
  • Posts: 44
Re: O2RadAsm
« Reply #11 on: March 05, 2018, 01:14:11 PM »
Hi Aurel

Quote
This PB dialogs drive me crazy...so whole DDT is based on Dialogs not Windows ,,right?

DDT is all based on Powerbasic proprietary code -- their own Dialogs and does not follow Windows conventions.
It is best to redo all these dialogs using Windows SDK

Aurel

  • Sr. Member
  • ****
  • Posts: 252
Re: O2RadAsm
« Reply #12 on: March 05, 2018, 02:24:21 PM »
Quote
It is best to redo all these dialogs using Windows SDK

hi Karen
yes works with dialogs are very crappy  >:(