Author Topic: Adventures in B  (Read 5907 times)

Aurel

  • Guest
Adventures in B
« 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  ::)
« Last Edit: March 13, 2019, 11:29:35 AM by Aurel »

Tomaaz

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

Aurel

  • Guest
Re: Adventures in B
« Reply #2 on: January 16, 2019, 06:41:24 PM »
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: March 13, 2019, 11:29:58 AM by Aurel »

Aurel

  • Guest
Re: Adventures in C
« Reply #3 on: January 16, 2019, 06:43:31 PM »
Just to let you know i am doing this without any GUI designer
..hmm maybe i need one ...

Tomaaz

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

  • Guest
Re: Adventures in B
« Reply #5 on: January 16, 2019, 06:56:29 PM »
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: March 13, 2019, 11:30:41 AM by Aurel »

Tomaaz

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

Aurel

  • Guest
Re: Adventures in C
« Reply #7 on: January 16, 2019, 07:30:52 PM »
What all comments  :o
probably i am stupid now because i don't get it what you mean under "all comments"  :o

Aurel

  • Guest
Re: Adventures in B
« Reply #8 on: January 16, 2019, 07:37:29 PM »
If you still not believe here is screenshot of Falcon C++ IDE with new project...
« Last Edit: March 13, 2019, 11:30:54 AM by Aurel »

Tomaaz

  • Guest
Re: Adventures in C
« Reply #9 on: January 16, 2019, 07:50:42 PM »
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: January 16, 2019, 08:18:14 PM »
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

  • Guest
Re: Adventures in B
« Reply #11 on: January 16, 2019, 09:44:22 PM »
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: March 13, 2019, 11:31:48 AM by Aurel »

Aurel

  • Guest
Re: Adventures in C
« Reply #12 on: January 16, 2019, 09:54:59 PM »
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;
}

Tomaaz

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

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

Aurel

  • Guest
Re: Adventures in C
« Reply #14 on: January 17, 2019, 07:39:03 AM »
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