RetroBASIC
Retrogamecoding(.org) => Other Languages => Topic started by: Aurel on January 16, 2019, 05:58:31 PM
-
well yes for me is adventures ;D
infact is not that bad because i already know some GUI api programming ..heh
most of things are same or similar just stupid syntax make me nervous ::)
-
What's the point of showing screenshots only. Post some code. It will be more interesting.
-
Aha..you need code ...
well code is some sort of secret .. ;D
of course is not here is as simple as can be
#include <windows.h>
#define IDC_MAIN_EDIT 200
/* window procedure */
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdParam, int cmdShow)
{
MSG messages; /* for messages queue manipulation */
WNDCLASSEX WndClass; /* data struct for window class */
HWND hWnd; /* handle for window */
/* define window class */
WndClass.cbSize = sizeof(WNDCLASSEX);
WndClass.style = CS_DBLCLKS;
WndClass.hInstance = hInst;
WndClass.lpszClassName = "WindowClassName";
WndClass.lpfnWndProc = WndProc;
/* icons, cursor and menu */
WndClass.hIcon = LoadIcon(hInst, "MAINICON"); /* default icon */
WndClass.hIconSm = LoadIcon(hInst, "MAINICON"); /* default icon */
WndClass.hCursor = LoadCursor(NULL, IDC_ARROW); /* cursor */
WndClass.lpszMenuName = NULL; /* no menu */
WndClass.cbClsExtra = 0;
WndClass.cbWndExtra = 0;
/* window background color */
WndClass.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
RegisterClassEx(&WndClass);
hWnd = CreateWindowEx(0, /* extended window style */
"WindowClassName", /* registered class */
"WinApp by Aurel", /* window title */
WS_OVERLAPPEDWINDOW, /* default window style */
CW_USEDEFAULT, /* x position */
CW_USEDEFAULT, /* y position */
880, /* width of window */
640, /* heigth of window */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* no menu */
hInst, /* Program Instance handler */
NULL); /* No Window Creation data */
ShowWindow(hWnd, SW_SHOW);
UpdateWindow(hWnd);
/* loop messages. run until GetMessage return 0*/
while (GetMessage(&messages, NULL, 0, 0))
{
TranslateMessage(&messages); /* translate virtual keys into character messages*/
DispatchMessage(&messages); /* Send message to WndProc */
}
/* return value to system */
return messages.wParam;
}
/* This function is called by the Windows function DispatchMessage() */
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
LPSTR ptext = "HDC[text]-Hello Falcon C++ by Aurel!";
LPSTR lyrics ="LINES";
switch (message)
{
//-------------------------------------------------------------------------
case WM_CREATE:
// -- STATIC CONTROL ---------------------------------------------
CreateWindowEx(0,"Static", lyrics,
WS_CHILD | WS_VISIBLE | SS_LEFT,
10, 10, 300, 20,
hwnd, (HMENU) 1, NULL, NULL);
//break; - no break important
// add Static control with bitmap from file ---------------------
HWND hStatic2;
hStatic2 = CreateWindowExA(0x200,"Static","",
WS_CHILD | WS_VISIBLE | SS_LEFT | SS_BITMAP,
560, 10, 300, 200,
hwnd, (HMENU) 2, NULL, NULL);
// load bitmap from file..........................................
HBITMAP hBitmap = (HBITMAP)LoadImage(NULL,"c:\\niceMan.bmp",
IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
if (hBitmap == NULL)
{
MessageBox(hwnd, "Could not Load Bitmap into Static box.", "Load Error", MB_OK | MB_ICONERROR);
}
SendMessage(hStatic2, 370, 0, hBitmap);
// ---EDIT CONTROL ---------------------------------------------------
HFONT hfDefault;
HWND hEdit;
hEdit = CreateWindowExA( 0x200, "Edit", "This is multiline Edit Control@",
WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL,
50, 60, 500, 400, hwnd, (HMENU)IDC_MAIN_EDIT , NULL, NULL);
if(hEdit == NULL)
{ // check!
MessageBox(hwnd, "Could not create edit box.", "Error", MB_OK | MB_ICONERROR);
}
UpdateWindow(hEdit);
hfDefault = GetStockObject(16);
SendMessage(hEdit, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
break;
//-------------------------------------------------------------------------
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
TextOut(hdc, 10, 540, ptext, strlen(ptext));
EndPaint(hwnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc(hwnd, message, wParam, lParam);
}
return 0;
}
-
Just to let you know i am doing this without any GUI designer
..hmm maybe i need one ...
-
Aurel, we know your English. This is a copy/paste work, ha ha ha! ;D You would never write comments like that. ;D ;D ;D
-
NULL, /* no menu */
hInst, /* Program Instance handler */
NULL); /* No Window Creation data */
you mean this comments ...
ha ha ..gee it is not copy/paste like you often do ::)
are you really that st**** dude this comments are added by Falcon C++ IDE
when you build new project...
do you get it now "expert" ;D
-
No, I mean all comments. ;D
-
What all comments :o
probably i am stupid now because i don't get it what you mean under "all comments" :o
-
If you still not believe here is screenshot of Falcon C++ IDE with new project...
-
This is a template from your IDE. You haven't written this code. You simply copied/posted it here. What is the point of copying/pasting templates? Please... ;D
-
Just to let you know. .cpp is an extension of C++ code. ;D ;D ;D You know that C++ and C are not exactly the same thing. Classes, objects, OOP... This is just brilliant! ;D ;D ;D
-
What you babeling this time :o
No it is pure C you "expert"
Sorry I understand that you don't know difference between C and C++. :'(
yes it is some sort of template if you looking on that in this way .
Something similar i wrote when i do awinh.inc include file for my Oxygen Basic
programming ...so it is just copy/paste too ?
NO is not copy/paste!
So ..do i need to do that here again in C when i can use this piece of code to
try some simple things ..NO i don't .
This code just create window with message loop and nothing else.
In fact i will put it into new include .h file to simplify coding.
would you like to know more "expert" ?
-
For "experts " like you Tomek here is C++ ;D
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <Windows.h>
//
//
// WndProc - Window procedure
//
//
LRESULT
CALLBACK
WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_DESTROY:
::PostQuitMessage(0);
break;
default:
return ::DefWindowProc(hWnd, uMsg, wParam, lParam);
}
return 0;
}
//
//
// WinMain - Win32 application entry point.
//
//
int
APIENTRY
wWinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPWSTR lpCmdLine,
int nShowCmd)
{
// Setup window class attributes.
WNDCLASSEX wcex;
ZeroMemory(&wcex, sizeof(wcex));
wcex.cbSize = sizeof(wcex); // WNDCLASSEX size in bytes
wcex.style = CS_HREDRAW | CS_VREDRAW; // Window class styles
wcex.lpszClassName = TEXT("MYFIRSTWINDOWCLASS"); // Window class name
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); // Window background brush color.
wcex.hCursor = LoadCursor(hInstance, IDC_ARROW); // Window cursor
wcex.lpfnWndProc = WndProc; // Window procedure associated to this window class.
wcex.hInstance = hInstance; // The application instance.
// Register window and ensure registration success.
if (!RegisterClassEx(&wcex))
return 1;
// Setup window initialization attributes.
CREATESTRUCT cs;
ZeroMemory(&cs, sizeof(cs));
cs.x = 0; // Window X position
cs.y = 0; // Window Y position
cs.cx = 640; // Window width
cs.cy = 480; // Window height
cs.hInstance = hInstance; // Window instance.
cs.lpszClass = wcex.lpszClassName; // Window class name
cs.lpszName = TEXT("My First Window"); // Window title
cs.style = WS_OVERLAPPEDWINDOW; // Window style
// Create the window.
HWND hWnd = ::CreateWindowEx(
cs.dwExStyle,
cs.lpszClass,
cs.lpszName,
cs.style,
cs.x,
cs.y,
cs.cx,
cs.cy,
cs.hwndParent,
cs.hMenu,
cs.hInstance,
cs.lpCreateParams);
// Validate window.
if (!hWnd)
return 1;
// Display the window.
::ShowWindow(hWnd, SW_SHOWDEFAULT);
::UpdateWindow(hWnd);
// Main message loop.
MSG msg;
while (::GetMessage(&msg, hWnd, 0, 0) > 0)
::DispatchMessage(&msg);
// Unregister window class, freeing the memory that was
// previously allocated for this window.
::UnregisterClass(wcex.lpszClassName, hInstance);
return (int)msg.wParam;
}
-
would you like to know more "expert" ?
Yes, please! It's always good to have a laugh. ;D ;D ;D
-
Look i know that you fooling around with me and you like "eat-the-shit" all the time but hey
there are other people who visit this place and that might destroy my good reputation >:(
;D
-
If you manage to learn something beyond BASIC it may actually destroy your bad reputation. ;)
-
If you manage to learn something beyond BASIC it may actually destroy your bad reputation
my reputation is not bad 8)
As i said before i will continue with C api programming
and testing some lexers/parsers ...this can help me to improve some things,
..and continue to work on my own editor in Oxygen Basic...
-
Is a new chapter coming soon? ;D
-
maybe...
'recursive descent token evaluator
#lookahead
int tc=0 : string token
string tokens[5]
tokens[1] = "2"
tokens[2] = "+"
tokens[3] = "3"
tokens[4] = "*"
tokens[5] = "4"
sub gettok(){
tc++
token = tokens[tc]
}
sub expr() as float{
float v = term()
if token = "+": gettok() : v = v + term(): end if
if token = "-": gettok() : v = v - term(): end if
return v
}
sub term() as float{
float v = factor()
if token = "*": gettok() : v = v * factor(): end if
if token = "/": gettok() : v = v / factor(): end if
return v
}
sub factor() as float{
if asc(token)>47 and asc(token)<58
float v = val(token)
end if
gettok()
return v
}
'exec-----------------
gettok() 'start
float res = expr()
print str res
-
and this one with parens
'recursive descent token evaluator
#lookahead
int tc=0 : string token
string tokens[7]
tokens[1] = "2"
tokens[2] = "*"
tokens[3] = "("
tokens[4] = "3"
tokens[5] = "+"
tokens[6] = "4"
tokens[7] = ")"
sub gettok()
tc++ : token = tokens[tc]
end sub
sub expr() as float
float v = term()
if token = "+": gettok() : v = v + term(): end if
if token = "-": gettok() : v = v - term(): end if
return v
end sub
sub term() as float
float v = factor()
if token = "*": gettok() : v = v * factor(): end if
if token = "/": gettok() : v = v / factor(): end if
return v
end sub
sub factor() as float
float v
if asc(token)>47 and asc(token)<58 'nums
v = val(token) : gettok()
end if
if asc(token)=40 and asc(token)<>41 'match (...)
gettok() : v = expr() : gettok()
end if
return v
end sub
'exec-----------------
gettok() 'start
float res = expr()
print str res
-
and tiny tokenizer
'microB tokenizer
int tkNULL=0,tkPLUS=1,tkMINUS=2,tkMULTI=3,tkDIVIDE=4
int tkCOLON=5,tkCOMMA=6,tkLPAREN=7,tkRPAREN=8,tkLBRACKET=9,tkRBRACKET=10
int tkPRINT=11,tkDOT=12,tkLINE=13,tkCIRCLE=14 ,tkEOL = 20
string tokList[256] : int typList[256] 'token/type arrays
int start , p = 1 ,start = p ,tp ,n 'init
string code,ch,tk ,crlf=chr(13)+chr(10),bf
code = "var1 + 2.5 " ' test or load_src?
sub tokenizer(src as string) as int
'ch = mid(src,p,1) : print "CH:" + ch' get first char
while p <= len(src)
ch = mid(src,p,1) 'get char
If asc(ch)=32 : p++ : end if 'skip blank space
If (asc(ch)>96 and asc(ch)<123) ' [a-z]
print "CH2:" + ch : p--
while (asc(ch)>96 and asc(ch)<123) or (asc(ch)>47 and asc(ch)<58) ' [a-z0-9]*
p++:ch = mid(src,p,1) : print "AZ:" + ch
tk =tk+ch
wend
print "TOK-AZ:" + tk
tp++ : tokList[tp] = tk : tk="" :p++
'return IDENT;
Elseif (asc(ch)>47 and asc(ch)<58) ' [0-9]
p--
while (asc(ch)>47 and asc(ch)<58) or (asc(ch)=46) '[0-9[0.0]]*
p++ : ch = mid(src,p,1):tk = tk + ch
wend
tp++ : tokList[tp] = tk : tk="":p++
'return NUMBER;
Elseif asc(ch)=43 ' [ + ]
tk = ch : tp++ : tokList[tp] = tk : tk="" :p++ ' set_token
'elseif...
End if
wend
return tp
end sub
'call tokenizer..tested(ident,numbers)
int tn: tn = tokenizer(code) : print "number of tokens:" + str(tn)
for n = 1 to tn : bf = bf + tokList[n] + crlf : next n
print bf
-
"Adventures in C" you say. Interesting... ???