Author Topic: WinH  (Read 24213 times)

0 Members and 1 Guest are viewing this topic.

Aurel

  • Guest
WinH
« on: September 12, 2011, 11:32:38 AM »
F

« Last Edit: September 25, 2014, 02:00:42 AM by Aurel »

Peter

  • Guest
Re: WinH
« Reply #1 on: September 12, 2011, 12:07:23 PM »
Where is  WINH.inc?   :D

kryton9

  • Guest
Re: WinH
« Reply #2 on: September 12, 2011, 01:02:22 PM »
Very nice start Aurel. Once you have it finished, we can add it to the help file.
Peter has lots of useful code, it is nice to see you making it usable for the rest of us.

I am thinking of making 3 sections:
1. Core Oxygen
2. Structured Programming
3. Object Oriented Programming

I will add these later today and then you can add your help to it when you have time.

Peter

  • Guest
Re: WinH
« Reply #3 on: September 12, 2011, 03:20:29 PM »
top secret!  I show you  in the mean time a better Font.
Code: [Select]
Include "window.h"

SetWindow("Top Secet",800,600,w_1)
sys_mode=4

cls 0xcf8c8c8
SetFont 14,32,0,"symbol"
SetText "This is proper size of...",20, 20,rgb(0,0,200)
SetText "Courier New font -> 10,400,flag-Italic=0",20, 40,rgb(0,0,200)
SetText "Font size start at 14 which is size 8",20, 60,rgb(0,0,200)

SetFont 12,32,0,"Courier New"
SetText "Courier New standard size -> 8,400,flag-Italic=0",20, 100,rgb(0,0,0)

SetFont 13,32,0,"times"
SetText "Times New standard size -> 9,400,flag-Italic=0",20, 120,rgb(200,0,0)

SetFont 14,32,0,""
SetText "Standard New standard size -> 10,400,flag-Italic=0",20, 140,rgb(0,0,200)

SetFont 15,32,0,"system"
SetText "System New standard size -> 11,400,flag-Italic=1",20, 160,rgb(0,140,0)


DoEvents
SwapBuffers
Pause

WinEnd

Peter

  • Guest
Re: WinH
« Reply #4 on: September 13, 2011, 05:12:21 AM »
Great   :D

Peter

  • Guest
Re: WinH
« Reply #5 on: September 16, 2011, 10:10:44 AM »
WNDCLASSEX seems for some reason not to work.
I had this problem earlier and gave up

Try this,
Code: [Select]
Type WNDCLASSEX
 cbSize        as long
 Style         as long
 lpfnwndproc   as long
 cbClsextra    as long
 cbWndExtra    as long
 hInstance     as long
 hIcon         as long
 hIconSm       as long
 hCursor       as long
 hbrBackground as long
 lpszMenuName  as long
 lpszClassName as long
End Type

Type WNDCLASS
 Style         as sys
 lpfnwndproc   as sys
 cbClsextra    as sys
 cbWndExtra    as sys
 hInstance     as sys
 hIcon         as sys
 hCursor       as sys
 hbrBackground as sys
 lpszMenuName  as sys
 lpszClassName as sys
End Type

Type Point
 x as sys
 y as sys
End Type

Type MSG
 hwnd    as sys
 message as sys
 wParam  as sys
 lParam  as sys
 time    as sys
 pt      as sys
 End Type

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

% IDI_APPLICATION= 32512
% CS_DBLCLKS     = 8
% SW_NORMAL      = 1
% SW_SHOWDEFAULT = 10
% SW_SHOW        = 5
% CS_VREDRAW     = 1
% CS_HREDRAW     = 2
% CS_OWNDC       = 32
% SM_CXSCREEN    = 0
% SM_CYSCREEN    = 1
% IDI_WINLOGO    = 32517
% IDC_ARROW      = 32512
% WM_CREATE      = 1
% WM_DESTROY     = 2
% WM_PAINT       = 15
% WM_QUIT        = 18
% WM_SIZE        = 5
% WM_MOVE        = 3
% WM_CHAR        = 258
% WM_KEYDOWN     = 256
% WM_KEYUP       = 257  
% WM_MOUSEMOVE   = 512
% WM_MBUTTONDOWN = 519
% WM_LBUTTONDOWN = 513
% WM_RBUTTONDOWN = 516
% WM_LBUTTONUP   = 514
% WM_RBUTTONUP   = 517
% WM_MBUTTONUP   = 520

% WS_OVERLAPPEDWINDOW  = 0x00cf0000
% WS_SYSMENU     = 524288
% WS_OVERLAPPED  = WS_SYSMENU    
% WS_POPUP       = 0x80000000
% WS_DLGFRAME    = 0x400000

% WHITE_BRUSH    = 0
% BLACK_BRUSH    = 4

Declare Function SetTextColor     Lib "gdi32.dll" (ByVal hdc As Long, ByVal crColor As Long) As Long
Declare Function TextOut          Lib "gdi32.dll" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long
Declare Function DestroyWindow    Lib "user32.dll" (ByVal hwnd As Long) As Long
Declare Function GetDC            Lib "user32.dll" (ByVal hwnd As Long) As Long
Declare Function SetBkColor       Lib "gdi32.dll" (ByVal hdc As Long, ByVal crColor As Long) As Long
Declare Function SetBkMode        Lib "gdi32.dll" (ByVal hdc As Long, ByVal nBkMode As Long) As Long
Declare Function CreateSolidBrush Lib "gdi32.dll" (ByVal crColor As Long) As Long
Declare Function GetStockObject   Lib "gdi32.dll" (ByVal nIndex As Long) As Long
Declare Function ReleaseDC        Lib "user32.dll" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Declare Function GetSystemMetrics Lib "user32.dll" (ByVal nIndex As Long) As Long
Declare Function ValidateRect     Lib "user32.dll" (ByVal hwnd As Long, ByRef lpRect As RECT) As Long
Declare Function InvalidateRect   Lib "user32.dll" (ByVal hwnd As Long, ByRef lpRect As RECT, ByVal bErase As Long) As Long
Declare Function DefWindowProc    Lib "user32.dll" Alias "DefWindowProcA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Declare Function ShowWindow       Lib "user32.dll" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Declare Function CreateWindowEx   Lib "user32.dll" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, ByRef lpParam As Any) As Long
Declare Function PostMessage      Lib "user32.dll" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Declare Function DispatchMessage  Lib "user32.dll" Alias "DispatchMessageA" (ByRef lpMsg As MSG) As Long
Declare Function TranslateMessage Lib "user32.dll" (ByRef lpMsg As MSG) As Long
Declare Function GetMessage       Lib "user32.dll" Alias "GetMessageA" (ByRef lpMsg As MSG, ByVal hwnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long) As Long
Declare Function SendMessage      Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByRef lParam As Any) As Long
Declare Function MessageBox       Lib "user32.dll" Alias "MessageBoxA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long
Declare Function RegisterClass    Lib "user32.dll" Alias "RegisterClassA" (ByRef Class As WNDCLASS) As Long
Declare Function RegisterClassEx  Lib "user32.dll" Alias "RegisterClassExA" (ByRef pcWndClassEx As WNDCLASSEX) As Long
Declare Function LoadCursor       Lib "user32.dll" Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As String) As Long
Declare Function LoadIcon         Lib "user32.dll" Alias "LoadIconA" (ByVal hInstance As Long, ByVal lpIconName As String) As Long
Declare Function GetCommandLine   Lib "kernel32.dll" Alias "GetCommandLineA" () As String
Declare Function GetModuleHandle  Lib "kernel32.dll" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long
Declare Function Beep             Lib "kernel32.dll" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long
Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As Long) As Integer
Declare Function GetPixel         Lib "gdi32.dll" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Declare Function SetPixel         Lib "gdi32.dll" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
Declare Function Rectangle        Lib "gdi32.dll" Alias "Rectangle" (ByVal hdc As Long, ByVal x1 As Long, ByVal y1 As Long, ByVal x2 As Long, ByVal y2 As Long) As Long
Declare Sub      ExitProcess      Lib "kernel32.dll" (ByVal uExitCode As Long)
Declare Sub      Sleep            Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Declare Sub      PostQuitMessage  Lib "user32.dll" (ByVal nExitCode As Long)

sys wx, wy, ww, wh, scr, inst, sys_hwnd, sys_hdc, caption, style

Dim wdx as WNDCLASSEX
Dim wm  as MSG
String s = "SIMPLE WINDOW"

Function HiWord(sys high) as sys
shr high,16
Return high
End Function

Function LoWord(sys low) as sys
and low,&hFFFF
Return low
End Function

Function WndProc(sys hWnd, wMsg, wParam, lparam) as long callback
iF wMsg = WM_CREATE
'
ElseiF wMsg = WM_PAINT
SetBkMode sys_hdc,1
SetTextColor sys_hdc,255
TextOut sys_hdc,240,200,s,Len(s)
SetTextColor sys_hdc,0x008000
TextOut sys_hdc,240,212,s,Len(s)
ValidateRect hwnd,  0
'
ElseiF wMsg = WM_DESTROY
PostQuitMessage 0
Else
Function = DefWindowProc hWnd,wMsg,wParam,lParam
End iF
End Function

inst = GetModuleHandle 0
wdx.cbSize = sizeof(WNDCLASSEX)
wdx.style  = CS_DBLCLKS
wdx.lpfnWndProc = &WndProc
wdx.cbClsExtra =0
wdx.cbWndExtra =0
wdx.hInstance  = inst
wdx.hIcon=LoadIcon 0,IDI_APPLICATION
wdcx.hIconSm=LoadIcon 0,IDI_APPLICATION        
wdx.hCursor=LoadCursor 0,IDC_ARROW      
wdx.hbrBackground = 1    
wdx.lpszMenuName  = caption
wdx.lpszClassName ="Winx"
RegisterClassEx (@wdx)
scr = GetSystemMetrics SM_CXSCREEN
wx  = (scr - 640) /2
Scr = GetSystemMetrics SM_CYSCREEN
wy  = (scr - 480) /2
sys_hwnd = CreateWindowEx 0, wdx.lpszClassName, caption, style, wx, wy, ww, wh, 0, 0, inst, 0
ShowWindow sys_hwnd, SW_SHOW
sys_hdc = GetDC(sys_hwnd)

While GetMessage &wm,0,0,0
iF wm.message = Wm_Quit
 ReleaseDC sys_hwnd,sys_hdc
 DestroyWindow sys_hwnd
 ExitProcess 0
End iF
TranslateMessage &wm
DispatchMessage  &wm
Wend

Peter

  • Guest
Re: WinH
« Reply #6 on: September 16, 2011, 10:35:20 AM »
Yes, good!  I need double buffer, then I can throw away OpenGl.

Charles Pegge

  • Guest
Re: WinH
« Reply #7 on: September 16, 2011, 10:47:16 AM »
Hi Aurel,

Correction to structure (moving hIconSmall to the end)

Code: OxygenBasic
  1.  
  2.   type WNDCLASSEX
  3.     cbSize        as long
  4.     Style         as long
  5.     lpfnwndproc   as long
  6.     cbClsextra    as long
  7.     cbWndExtra    as long
  8.     hInstance     as long
  9.     hIcon         as long
  10.     hCursor       as long
  11.     hbrBackground as long
  12.     lpszMenuName  as long
  13.     lpszClassName as long
  14.     hIconSm       as long
  15.   end type
  16.  

Also:

lpszClassName and lpszMenuName have been defined as long rather than zString pointers so you will need pass the string pointer to these variables thus:


string ClassName="Winx", MenuName="Menu"

then


wc.lpszClassName=*ClassName
wc.lpszMenuName=*MenuName


I will add RegisterClassEx to MinWin.inc.

Charles
« Last Edit: September 17, 2011, 12:28:05 AM by Charles Pegge »

Peter

  • Guest
Re: WinH
« Reply #8 on: September 16, 2011, 11:42:00 AM »
Not any double Buffer here !
This is what I am doing the whole time.

A double buffer alternates its sides, one for mother, one for father.

Charles Pegge

  • Guest
Re: WinH
« Reply #9 on: May 02, 2012, 12:30:05 AM »

Hi Aurel,

To get your program working with the new Oxygen:

wcx.lpszMenuName  = strptr caption
wcx.lpszClassName = strptr "Winx"

This is because these elements have been defined as long in the header, and strptr ensures that a string pointer is always returned.


Code: [Select]
Function SetWindow (byval caption as string ,byval Wx as int,byval Wy as int, byval Ww as int, byval Wh as int, byval wparent as int, byval style as int) as int
inst = GetModuleHandle 0
'wcx.cbSize = sizeof(WNDCLASSEX)
wcx.style = CS_DBLCLKS
wcx.lpfnWndProc = &WndProc
wcx.cbClsExtra =0
wcx.cbWndExtra =0
wcx.hInstance  = inst
wcx.hIcon=LoadIcon 0,IDI_APPLICATION
'wcx.hIconSm=LoadIcon 0,IDI_APPLICATION         
wcx.hCursor=LoadCursor 0,IDC_ARROW       
wcx.hbrBackground =  1   
wcx.lpszMenuName  = strptr caption
wcx.lpszClassName = strptr "Winx"

RegisterClass &wcx

Charles

Charles Pegge

  • Guest
Re: WinH
« Reply #10 on: May 30, 2012, 07:46:19 AM »
Hi Aurel,

Could you post your latest awinh.inc.
The version I have (2 May 2012) is not compatible.

Charles

kryton9

  • Guest
Re: WinH
« Reply #11 on: May 30, 2012, 08:30:35 AM »
If you guys want, I can create an FTP account for you guys on my webserver, For Peter, Aurel and Charles, this way you can keep all of the latest code that is yours for Oxygen in one place and then Charles could get the files from there and we won't have to go through all the forum posts to get stuff. That is why I don't reply to lot of Peter's and Aurel's posts as my files are always out of date and things just don't run.

kryton9

  • Guest
Re: WinH
« Reply #12 on: May 31, 2012, 03:39:16 PM »
Here is a screenshot of how it works on my computer Aurel.

Charles Pegge

  • Guest
Re: WinH
« Reply #13 on: June 01, 2012, 01:33:24 AM »

Thanks Aurel :)

kryton9

  • Guest
Re: WinH
« Reply #14 on: June 01, 2012, 04:01:59 PM »
Nice artwork on the icons Aurel.