Retrogamecoding(.org) > Other Languages
Adventures in B
Aurel:
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 ::)
Tomaaz:
What's the point of showing screenshots only. Post some code. It will be more interesting.
Aurel:
Aha..you need code ...
well code is some sort of secret .. ;D
of course is not here is as simple as can be
--- Code: ---#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;
}
--- End code ---
Aurel:
Just to let you know i am doing this without any GUI designer
..hmm maybe i need one ...
Tomaaz:
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
Navigation
[0] Message Index
[#] Next page
Go to full version