Author Topic: Adventures in B  (Read 1892 times)

Aurel

  • Regular Member
  • Hero Member
  • *
  • Posts: 605
    • View Profile
Adventures in B
« on: 16. January 2019, 18:58:31 »
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  ::)
« Last Edit: 13. March 2019, 12:29:35 by Aurel »
my site:BLOG and FORUM
https://aurelsoft.ucoz.com/

Tomaaz

  • Guest
Re: Adventures in C
« Reply #1 on: 16. January 2019, 19:24:42 »
What's the point of showing screenshots only. Post some code. It will be more interesting.

Aurel

  • Regular Member
  • Hero Member
  • *
  • Posts: 605
    • View Profile
Re: Adventures in B
« Reply #2 on: 16. January 2019, 19:41:24 »
Aha..you need code ...
well code is some sort of secret .. ;D

of course is not here is as simple as can be

Code: [Select]
#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;
}
« Last Edit: 13. March 2019, 12:29:58 by Aurel »
my site:BLOG and FORUM
https://aurelsoft.ucoz.com/

Aurel

  • Regular Member
  • Hero Member
  • *
  • Posts: 605
    • View Profile
Re: Adventures in C
« Reply #3 on: 16. January 2019, 19:43:31 »
Just to let you know i am doing this without any GUI designer
..hmm maybe i need one ...
my site:BLOG and FORUM
https://aurelsoft.ucoz.com/

Tomaaz

  • Guest
Re: Adventures in C
« Reply #4 on: 16. January 2019, 19:51:42 »
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

Aurel

  • Regular Member
  • Hero Member
  • *
  • Posts: 605
    • View Profile
Re: Adventures in B
« Reply #5 on: 16. January 2019, 19:56:29 »
Quote
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
« Last Edit: 13. March 2019, 12:30:41 by Aurel »
my site:BLOG and FORUM
https://aurelsoft.ucoz.com/

Tomaaz

  • Guest
Re: Adventures in C
« Reply #6 on: 16. January 2019, 20:21:52 »
No, I mean all comments.  ;D

Aurel

  • Regular Member
  • Hero Member
  • *
  • Posts: 605
    • View Profile
Re: Adventures in C
« Reply #7 on: 16. January 2019, 20:30:52 »
What all comments  :o
probably i am stupid now because i don't get it what you mean under "all comments"  :o
my site:BLOG and FORUM
https://aurelsoft.ucoz.com/

Aurel

  • Regular Member
  • Hero Member
  • *
  • Posts: 605
    • View Profile
Re: Adventures in B
« Reply #8 on: 16. January 2019, 20:37:29 »
If you still not believe here is screenshot of Falcon C++ IDE with new project...
« Last Edit: 13. March 2019, 12:30:54 by Aurel »
my site:BLOG and FORUM
https://aurelsoft.ucoz.com/

Tomaaz

  • Guest
Re: Adventures in C
« Reply #9 on: 16. January 2019, 20:50:42 »
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

Tomaaz

  • Guest
Re: Adventures in C
« Reply #10 on: 16. January 2019, 21:18:14 »
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

Aurel

  • Regular Member
  • Hero Member
  • *
  • Posts: 605
    • View Profile
Re: Adventures in B
« Reply #11 on: 16. January 2019, 22:44:22 »
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" ?
« Last Edit: 13. March 2019, 12:31:48 by Aurel »
my site:BLOG and FORUM
https://aurelsoft.ucoz.com/

Aurel

  • Regular Member
  • Hero Member
  • *
  • Posts: 605
    • View Profile
Re: Adventures in C
« Reply #12 on: 16. January 2019, 22:54:59 »
For "experts " like you Tomek here is C++  ;D

Code: [Select]
#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;
}
my site:BLOG and FORUM
https://aurelsoft.ucoz.com/

Tomaaz

  • Guest
Re: Adventures in C
« Reply #13 on: 16. January 2019, 23:26:38 »
would you like to know more "expert" ?

Yes, please! It's always good to have a laugh.   ;D ;D ;D

Aurel

  • Regular Member
  • Hero Member
  • *
  • Posts: 605
    • View Profile
Re: Adventures in C
« Reply #14 on: 17. January 2019, 08:39:03 »
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
my site:BLOG and FORUM
https://aurelsoft.ucoz.com/