April 25, 2024, 02:04:40 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Aurora and Windows SDK style

Started by JR, July 16, 2006, 10:44:03 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

JR

I would like to know if there are any issues using Aurora with pure Windows SDK style, i.e. registering your own class and using a message pump and a procedure callback.

Ionic Wind Support Team

Not that I am aware of.  Considering that the Aurora window classes are written in Aurora ;)

Ionic Wind Support Team

JR

Thanks. I will need to write a program in Windows SDK style and wanted to be sure first.

Rock Ridge Farm (Larry)

Keep us posted on your progress - we can allways use this in the Aurora feature list
as a purchace point.

JR

August 05, 2006, 10:49:44 PM #4 Last Edit: August 05, 2006, 10:51:50 PM by José Roca
Well. Today I have found time to made a test. The Hello Windows program, of course :)

It works, but I have a couple of questions:

global sub main has no parameters. I can retrieve the hInstance with GetModuleHandle, but how can I retrieve the lpCmdLine and nCmdShow parameters?

Does Aurora support static variables?

This is the test code:


/*
  *Window Styles
*/
#define WS_OVERLAPPED       0x00000000
#define WS_POPUP            0x80000000
#define WS_CHILD            0x40000000
#define WS_MINIMIZE         0x20000000
#define WS_VISIBLE          0x10000000
#define WS_DISABLED         0x08000000
#define WS_CLIPSIBLINGS     0x04000000
#define WS_CLIPCHILDREN     0x02000000
#define WS_MAXIMIZE         0x01000000
#define WS_CAPTION          0x00C00000     /*WS_BORDER | WS_DLGFRAME  */
#define WS_BORDER           0x00800000
#define WS_DLGFRAME         0x00400000
#define WS_VSCROLL          0x00200000
#define WS_HSCROLL          0x00100000
#define WS_SYSMENU          0x00080000
#define WS_THICKFRAME       0x00040000
#define WS_GROUP            0x00020000
#define WS_TABSTOP          0x00010000
#define WS_MINIMIZEBOX      0x00020000
#define WS_MAXIMIZEBOX      0x00010000
#define WS_TILED            WS_OVERLAPPED
#define WS_ICONIC           WS_MINIMIZE
#define WS_SIZEBOX          WS_THICKFRAME

/*
  *Common Window Styles
*/
#define WS_OVERLAPPEDWINDOW (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX)
#define WS_TILEDWINDOW      WS_OVERLAPPEDWINDOW
#define WS_POPUPWINDOW      (WS_POPUP | WS_BORDER | WS_SYSMENU)
#define WS_CHILDWINDOW      (WS_CHILD)

/*
  *Class styles
*/
#define CS_VREDRAW          0x0001
#define CS_HREDRAW          0x0002
#define CS_DBLCLKS          0x0008
#define CS_OWNDC            0x0020
#define CS_CLASSDC          0x0040
#define CS_PARENTDC         0x0080
#define CS_NOCLOSE          0x0200
#define CS_SAVEBITS         0x0800
#define CS_BYTEALIGNCLIENT  0x1000
#define CS_BYTEALIGNWINDOW  0x2000
#define CS_GLOBALCLASS      0x4000

#define CS_IME              0x00010000
#define CS_DROPSHADOW       0x00020000

#define IDI_APPLICATION     32512
#define IDI_HAND            32513
#define IDI_QUESTION        32514
#define IDI_EXCLAMATION     32515
#define IDI_ASTERISK        32516
#define IDI_WINLOGO         32517
#define IDI_WARNING     IDI_EXCLAMATION
#define IDI_ERROR       IDI_HAND
#define IDI_INFORMATION IDI_ASTERISK

#define CW_USEDEFAULT       0x80000000

/*
  *Window Messages
*/

#define WM_NULL                         0x0000
#define WM_CREATE                       0x0001
#define WM_DESTROY                      0x0002
#define WM_MOVE                         0x0003
#define WM_SIZE                         0x0005
#define WM_ACTIVATE                     0x0006
/*
  *WM_ACTIVATE state values
*/
#define     WA_INACTIVE     0
#define     WA_ACTIVE       1
#define     WA_CLICKACTIVE  2

#define WM_SETFOCUS                     0x0007
#define WM_KILLFOCUS                    0x0008
#define WM_ENABLE                       0x000A
#define WM_SETREDRAW                    0x000B
#define WM_SETTEXT                      0x000C
#define WM_GETTEXT                      0x000D
#define WM_GETTEXTLENGTH                0x000E
#define WM_PAINT                        0x000F
#define WM_CLOSE                        0x0010
#define WM_QUERYENDSESSION              0x0011
#define WM_QUERYOPEN                    0x0013
#define WM_ENDSESSION                   0x0016
#define WM_QUIT                         0x0012
#define WM_ERASEBKGND                   0x0014
#define WM_SYSCOLORCHANGE               0x0015
#define WM_SHOWWINDOW                   0x0018
#define WM_WININICHANGE                 0x001A
#define WM_SETTINGCHANGE                WM_WININICHANGE
#define WM_DEVMODECHANGE                0x001B
#define WM_ACTIVATEAPP                  0x001C
#define WM_FONTCHANGE                   0x001D
#define WM_TIMECHANGE                   0x001E
#define WM_CANCELMODE                   0x001F
#define WM_SETCURSOR                    0x0020
#define WM_MOUSEACTIVATE                0x0021
#define WM_CHILDACTIVATE                0x0022
#define WM_QUEUESYNC                    0x0023
#define WM_GETMINMAXINFO                0x0024

#define WM_PAINTICON                    0x0026
#define WM_ICONERASEBKGND               0x0027
#define WM_NEXTDLGCTL                   0x0028
#define WM_SPOOLERSTATUS                0x002A
#define WM_DRAWITEM                     0x002B
#define WM_MEASUREITEM                  0x002C
#define WM_DELETEITEM                   0x002D
#define WM_VKEYTOITEM                   0x002E
#define WM_CHARTOITEM                   0x002F
#define WM_SETFONT                      0x0030
#define WM_GETFONT                      0x0031
#define WM_SETHOTKEY                    0x0032
#define WM_GETHOTKEY                    0x0033
#define WM_QUERYDRAGICON                0x0037
#define WM_COMPAREITEM                  0x0039
#define WM_GETOBJECT                    0x003D
#define WM_COMPACTING                   0x0041
#define WM_COMMNOTIFY                   0x0044  /*no longer suported */
#define WM_WINDOWPOSCHANGING            0x0046
#define WM_WINDOWPOSCHANGED             0x0047
#define WM_POWER                        0x0048

/*
  *Standard Cursor IDs
*/
#define IDC_ARROW           32512
#define IDC_IBEAM           32513
#define IDC_WAIT            32514
#define IDC_CROSS           32515
#define IDC_UPARROW         32516
#define IDC_SIZE            32640  /*OBSOLETE: use IDC_SIZEALL */
#define IDC_ICON            32641  /*OBSOLETE: use IDC_ARROW */
#define IDC_SIZENWSE        32642
#define IDC_SIZENESW        32643
#define IDC_SIZEWE          32644
#define IDC_SIZENS          32645
#define IDC_SIZEALL         32646
#define IDC_NO              32648 /*not in win3.1 */
#define IDC_HAND            32649
#define IDC_APPSTARTING     32650 /*not in win3.1 */
#define IDC_HELP            32651

/* Stock Logical Objects */
#define WHITE_BRUSH         0
#define LTGRAY_BRUSH        1
#define GRAY_BRUSH          2
#define DKGRAY_BRUSH        3
#define BLACK_BRUSH         4
#define NULL_BRUSH          5
#define HOLLOW_BRUSH        NULL_BRUSH
#define WHITE_PEN           6
#define BLACK_PEN           7
#define NULL_PEN            8
#define OEM_FIXED_FONT      10
#define ANSI_FIXED_FONT     11
#define ANSI_VAR_FONT       12
#define SYSTEM_FONT         13
#define DEVICE_DEFAULT_FONT 14
#define DEFAULT_PALETTE     15
#define SYSTEM_FIXED_FONT   16

/*
  *ShowWindow() Commands
*/
#define SW_HIDE             0
#define SW_SHOWNORMAL       1
#define SW_NORMAL           1
#define SW_SHOWMINIMIZED    2
#define SW_SHOWMAXIMIZED    3
#define SW_MAXIMIZE         3
#define SW_SHOWNOACTIVATE   4
#define SW_SHOW             5
#define SW_MINIMIZE         6
#define SW_SHOWMINNOACTIVE  7
#define SW_SHOWNA           8
#define SW_RESTORE          9
#define SW_SHOWDEFAULT      10
#define SW_FORCEMINIMIZE    11
#define SW_MAX              11

/*
  *DrawText() Format Flags
*/
#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

#define DT_EDITCONTROL              0x00002000
#define DT_PATH_ELLIPSIS            0x00004000
#define DT_END_ELLIPSIS             0x00008000
#define DT_MODIFYSTRING             0x00010000
#define DT_RTLREADING               0x00020000
#define DT_WORD_ELLIPSIS            0x00040000
#define DT_NOFULLWIDTHCHARBREAK     0x00080000
#define DT_HIDEPREFIX               0x00100000
#define DT_PREFIXONLY               0x00200000

/*
*  flag values for fuSound and fdwSound arguments on [snd]PlaySound
*/
#define SND_SYNC            0x0000  /* play synchronously (default) */
#define SND_ASYNC           0x0001  /* play asynchronously */
#define SND_NODEFAULT       0x0002  /* silence (!default) if sound not found */
#define SND_MEMORY          0x0004  /* pszSound points to a memory file */
#define SND_LOOP            0x0008  /* loop the sound until next sndPlaySound */
#define SND_NOSTOP          0x0010  /* don't stop any currently playing sound */

#define SND_NOWAIT      0x00002000 /* don't wait if the driver is busy */
#define SND_ALIAS       0x00010000 /* name is a registry alias */
#define SND_ALIAS_ID    0x00110000 /* alias is a predefined ID */
#define SND_FILENAME    0x00020000 /* name is file name */
#define SND_RESOURCE    0x00040004 /* name is resource name or atom */
#define SND_PURGE           0x0040  /* purge non-static events for task */
#define SND_APPLICATION     0x0080  /* look for application specific association */

#define SND_ALIAS_START 0           /* alias base */

//#define sndAlias(ch0, ch1)      (SND_ALIAS_START + (DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8))

#define SND_ALIAS_SYSTEMASTERISK        0x2A53
#define SND_ALIAS_SYSTEMQUESTION        0x3F53
#define SND_ALIAS_SYSTEMHAND            0x4853
#define SND_ALIAS_SYSTEMEXIT            0x4553
#define SND_ALIAS_SYSTEMSTART           0x5353
#define SND_ALIAS_SYSTEMWELCOME         0x5753
#define SND_ALIAS_SYSTEMEXCLAMATION     0x2153
#define SND_ALIAS_SYSTEMDEFAULT         0x4453

import int PlaySound alias PlaySoundA(
   pointer pszSound,
   unsigned int hmod,
   unsigned int fdwSound);

struct WNDCLASS {
   unsigned int  style;
   pointer       *lpfnWndProc;
   int           cbClsExtra;
   int           cbWndExtra;
   unsigned int  hInstance;
   unsigned int  hIcon;
   unsigned int  hCursor;
   unsigned int  hbrBackground;
   unsigned byte *lpszMenuName;
   unsigned byte *lpszClassName;
}

import unsigned word RegisterClass alias RegisterClassA(WNDCLASS *lpWndClass);

/*
import unsigned int CreateWindow alias CreateWindowA(
   pointer      *lpClassName,
   pointer      lpWindowName,
   unsigned int dwStyle,
   int          x,
   int          y,
   int          nWidth,
   int          nHeight,
   unsigned int hWndParent,
   unsigned int hMenu,
   unsigned int hInstance,
   pointer      *lpParam);
*/

import unsigned int CreateWindowEx alias CreateWindowExA(
   unsigned int dwExStyle,
   pointer      *lpClassName,
   pointer      lpWindowName,
   unsigned int dwStyle,
   int          x,
   int          y,
   int          nWidth,
   int          nHeight,
   unsigned int hWndParent,
   unsigned int hMenu,
   unsigned int hInstance,
   pointer      *lpParam);

import unsigned int GetStockObject(int fnObject);

import int ShowWindow(
unsigned int hWnd,
int nCmdShow);

import int UpdateWindow(unsigned int hWnd);

struct RECT
{
    int left;
    int top;
    int right;
    int bottom;
}

struct PAINTSTRUCT {
   unsigned int hdc;
   int          fErase;
   RECT         rcPaint;
   int          fRestore;
   int          fIncUpdate;
   byte         rgbReserved[32];
}

import unsigned int BeginPaint(
unsigned  int hWnd,
   pointer  *lpPaint);

import int EndPaint(
unsigned int  hWnd,
PAINTSTRUCT  *lpPaint);

import int GetClientRect(
unsigned  int hWnd,
   pointer  *lpRect);

import unsigned int LoadIcon alias LoadIconA(
unsigned  int hInstance,
pointer  *lpIconName);

import unsigned int LoadCursor alias LoadCursorA(
unsigned int hInstance,
pointer  *lpCursorName);

struct POINT
{
    int x;
    int y;
}

struct MSG
{
   unsigned int hwnd;
   unsigned int message;
   unsigned int wParam;
   int          lParam;
   unsigned int time;
   POINT        pt;
}

import int GetMessage alias GetMessageA(
   MSG          *lpMsg,
unsigned int  hWnd,
unsigned int  wMsgFilterMin,
unsigned int  wMsgFilterMax);

import int TranslateMessage(MSG *message);

import int DispatchMessage alias DispatchMessageA(MSG *message);

import void PostQuitMessage(int nExitCode);

import int DefWindowProc alias DefWindowProcA(
unsigned int hWnd,
unsigned int Msg,
unsigned int wParam,
int          lParam);

import int DrawText alias DrawTextA(
unsigned int  hdc,
    pointer      *lpchText,
int           cchText,
RECT         *lprc,
unsigned int  format);

import unsigned int GetModuleHandle alias GetModuleHandleA(
    pointer *lpModuleName);


global sub main()
{

     szAppName = "HelloWin" ;
     szCaption = "The Hello Program" ;
     unsigned int hwnd ;
     MSG msg ;
     WNDCLASS wndclass ;
unsigned int hInstance ;

hInstance = GetModuleHandle(0) ;

     wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
     wndclass.lpfnWndProc   = &WndProc ;
     wndclass.cbClsExtra    = 0 ;
     wndclass.cbWndExtra    = 0 ;
     wndclass.hInstance     = hInstance ;
     wndclass.hIcon         = LoadIcon (NULL, IDI_APPLICATION) ;
     wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
     wndclass.hbrBackground = GetStockObject (WHITE_BRUSH) ;
     wndclass.lpszMenuName  = NULL ;
     wndclass.lpszClassName = szAppName ;

     if (!RegisterClass (&wndclass))
        return 0 ;

     hwnd = CreateWindowEx (0,                          // extended style
                        szAppName,                  // window class name
                            szCaption,                  // window caption
                            WS_OVERLAPPEDWINDOW,        // window style
                            CW_USEDEFAULT,              // initial x position
                            CW_USEDEFAULT,              // initial y position
                            CW_USEDEFAULT,              // initial x size
                            CW_USEDEFAULT,              // initial y size
                            NULL,                       // parent window handle
                            NULL,                       // window menu handle
                            hInstance,                  // program instance handle
                            NULL) ;                     // creation parameters

     ShowWindow (hwnd, SW_SHOWNORMAL) ;
     UpdateWindow (hwnd) ;

     while (GetMessage (&msg, NULL, 0, 0))
     {
          TranslateMessage (&msg) ;
          DispatchMessage (&msg) ;
     }
     return msg.wParam ;

}

SUB WndProc (unsigned int hwnd, unsigned int message, unsigned int wParam, int lParam), int
{
     unsigned int hdc ;
     PAINTSTRUCT  ps ;
     RECT         rect ;

     switch (message)
     {
     case WM_CREATE:
//          PlaySound ("hellowin.wav", NULL, SND_FILENAME | SND_ASYNC) ;
          return 0 ;

     case WM_PAINT:
          hdc = BeginPaint (hwnd, &ps) ;

          GetClientRect (hwnd, &rect) ;

          DrawText (hdc, "Hello, Windows 98!", -1, &rect,
                    DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;

          EndPaint (hwnd, &ps) ;
          return 0 ;

     case WM_DESTROY:
          PostQuitMessage (0) ;
          return 0 ;
     }
     return DefWindowProc (hwnd, message, wParam, lParam) ;
}


Ionic Wind Support Team

Use the API functions GetCommandLine(A/W) and GetStartupInfo(A/W). 

C uses these functions before calling WinMain to fill in argc/argv and nCmdShow.  So if your doing straight API programming you'll need to use them too.

And no, there isn't static variable support.




Ionic Wind Support Team

JR

Thanks for the info. I wasn't aware of these functions because I never had the need to use them before.

Please, put a big tick with my name in your wish list for adding support for static variables.

Ionic Wind Support Team

A static variable in C is really a global variable.  You can simulate the same in Aurora.

int mysub_a = 1;
sub mysub()
{
     mysub_a++;
     
}
Ionic Wind Support Team