Hi J. P. Morgan,
Re: Slumming it with Java and C#.
You commented,
" Yes, but VB6 got them beat by many years.
VB devolves the high and noble c down to the street level
-- where any bum can program.
c# and java are just fancy names for VB6. "
Basic and C are about the same age, I assume.
But that's were the similarities end,
C was built for real work, from the ground up.
As for Visual Basic,
No Visual C for me ... It just makes things harder.
For example,
My multi-client, RRR_Puppy, has only one window as a rule.
No pop-ups for me, thank you.
And it's nothing to create that window, in WinMain() I do:
#define LOOP while ( 1 )
#define CW CreateWindow
typedef unsigned int uint;
int Left_Scr, Top_Scr, W_Me, H_Me, Right_Scr, Bot_Scr ;
HINSTANCE PID ; HFONT Fnt ;
typedef char * Line ;
enum { Sz_Ptr = sizeof Line,
Vis = WS_VISIBLE, Chi = WS_CHILD };
// Big-ER and little-er ... Get it ?
int ER ( int X, int Y ) { return X > Y ? X : Y ; }
int er ( int X, int Y ) { return X < Y ? X : Y ; }
int __stdcall WinMain( HINSTANCE _PID, HINSTANCE x0,
LPSTR CmdLn, int x1) { PID = _PID ;
{ long R [ 4 ];
SystemParametersInfo(
SPI_GETWORKAREA, 0, ( RECT * ) R, 0 );
Right_Scr = R[2]; Bot_Scr = R[ 3 ]; R
[ 2 ] -= R[ 0 ]; R[ 3 ] -= R[ 1 ];
Left_Scr = R[ 0 ]; Top_Scr = R[ 1 ];
W_Me = R[ 2 ]; H_Me = R[ 3 ]; }
float Sca = W_Me / 640.;
Rec_Me = _R( 0, 0, W_Me, H_Me );
.....
{ float Width = Sca * ( Font_Sz ); SIZE Sz;
Fnt = CreateFont( -Rnd( 81* Width/ 49 ),
0,0,0, 0 ,0,0,0,0,0,0,0,
FIXED_PITCH, "Lucida Console");
SetPtr( DC, Fnt );
GetTextExtentPoint( DC,"XXXXX", 5, & Sz );
// Character width and hight,
// one size, and one size only.
W = Rnd( Sz.cx / 5. ); H = Sz.cy;
// Columns and Rows, about 64 by 26.
Col_Me = W_Me / W ; Row_Me = H_Me / H ; }
{ WNDCLASS Class = {
0, WinProc, 0, 0, PID, 0, 0, 0, 0, "WinProc" };
RegisterClass( & Class ); }
{ WNDCLASS Class = {
0, WinProc, 0, 0, PID, 0, 0, 0, 0, "WinProcN" };
RegisterClass( & Class ); }
Win = CW("WinProc", "RRR_Puppy",
Vis | WS_POPUP | WS_EX_TOPMOST,
Left_Scr, Top_Scr, W_Me, H_Me, 0,0,PID,0);
// This is needed because of the way I minimize
// all tasks on WM_ACTIVATEAPP, see below.
ShowWindow( Win, SW_RESTORE );
.....
// Minimizes all tasks on WM_ACTIVATEAPP,
// except sometimes Win, which is my task.
int __stdcall Min_All ( HWND A_Win, long Z ) {
if ( A_Win == Win && ShowTime ) return 1 ;
int Style = GetWindowLong( A_Win, GWL_EXSTYLE );
if ( IsWindowVisible ( A_Win ) &&
! ( Style & WS_EX_TOOLWINDOW )
&& ( Style & WS_EX_APPWINDOW ||
! GetParent ( A_Win ) ) && ! IsIconic ( A_Win ) )
ShowWindow( A_Win, SW_MINIMIZE ); return 1 ; }
long __stdcall WinProc (
HWND Wnd, uint M, uint C, long C2 ) {
if ( M == WM_PAINT ) { Paint_Req = 1;
ValidateRect( Win, & Rec_Me ); return 0; }
if ( M == WM_ACTIVATEAPP ) { static int Ignore ;
if ( Ignore ) return 0 ;
ShowTime = ( ushort ) C ; Ignore = 1 ;
EnumWindows ( Min_All, 0 ); Ignore = 0 ;
if ( Sur_Scr && ShowTime ) { Paint_Req = 1;
Sur_Scr->Restore(); Sur_Draw->Restore(); Is_In = 0;
ShowWindow( Win, SW_RESTORE ); } }
return DefWindowProc( Wnd, M, C, C2); }
.....
But if, for some bizarre reason, I don't have enough
VRAM for Direct Draw 7 or something,
I will pop up an error window at the very start,
But that's the Only pop-up that I allow, I do this:
long __stdcall
WinProcN ( HWND Wnd, uint WM, uint wp, long lp ) {
return DefWindowProc( Wnd, WM, wp,lp ); }
Fatal ( Line S, ... ) { char B [ 300 ];
int Max = 0, Row = -1,
L = vsprintf( B, S, ( Line ) & S + Sz_Ptr );
Line E = B + L, Y = B, X ; * E ++ = '\n'; * E = 0 ;
LOOP { Row ++ ; X = Y ; Y = strchr ( X, '\n' );
if ( ! Y ) break ; L = Y - X ; if ( L > Max ) Max = L;
memmove( Y + 1, Y, E - Y + 1); E ++ ;
* Y = '\r'; Y += 2 ; }
float W_Mess = ( Max + 4 ) * W,
H_Mess = ( Row + 3 ) * H ;
HWND O, Txt, _Win =
CW( "WinProcN", "Notice", WS_POPUP | Vis | WS_CAPTION,
ER( 0, ( Right_Scr - W_Mess ) / 2),
( Bot_Scr - H_Mess ) / 2,
W_Mess, H_Mess, 0,0,PID,0 );
Txt= CW("EDIT", B, Chi | ES_MULTILINE | ES_NOHIDESEL,
W, 0, W_Mess, Row * H, _Win, 0, PID,0);
SendMessage( Txt, WM_SETFONT, ( int ) Fnt, 1 );
ShowWindow( Txt, SW_SHOW ); float _W = W * 3.5;
O = CreateWindow("BUTTON","Ok", BS_PUSHBUTTON | Chi,
( W_Mess - _W ) / 2, Row * H, _W, H * 1.3,
_Win, ( HMENU ) 1, PID, 0 );
SendMessage( O, WM_SETFONT, ( int ) Fnt, 1 );
ShowWindow( O, SW_SHOW ); SetForegroundWindow( O );
while( GetMessage( & Msg ,0,0,0 ) ) {
TranslateMessage( & Msg ); DispatchMessage( & Msg );
if( Msg.message == WM_KEYDOWN && Msg.wParam == 27
|| Msg.message == WM_LBUTTONUP
&& ( int ) GetMenu( Msg.hwnd ) == 1 ) break ; }
DestroyWindow( _Win ); exit( 1 ); }
See Bailo ?
There's nothing to it, no need for Visual anything.
And that Fatal() routine even allows one
to cut and paste the error message.