Post Reply 
Social Buttons
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hello Ed -2!
01-09-2019, 01:05 AM
Post: #21
RE: Hello Ed -2!
Is there a faster why to do that in C ..
maybe somone alredy create HDC include for C win gui programming
of course without extra large include (header file) ?
Find all posts by this user
Quote this message in a reply
01-09-2019, 03:23 AM
Post: #22
RE: Hello Ed -2!
Ed
Just to let you know your example return error
" unreferenced TextOutA@'20 "
what kind of error is that ????
Find all posts by this user
Quote this message in a reply
01-09-2019, 04:07 AM
Post: #23
RE: Hello Ed -2!
Also ..this example also complain about TextOut@20'

Code:
// How to print text in Win32 C/C++
// Auther: -LeetGamer-

#include <Windows.h>
int iLoopCounter;
HINSTANCE hInstance;

// Function I made to get the size of the text
int GetTextSize (LPSTR a0)
{
    for (iLoopCounter = 0; ;iLoopCounter++)
    {
        if (a0 [iLoopCounter] == '\0')
            return iLoopCounter;
    }
}

LPSTR TextArray [] = {
    "Hello World"
};

LRESULT CALLBACK WndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch (msg)
    {
        case WM_CLOSE:
        DestroyWindow (hwnd);
        break;

        case WM_DESTROY:
        PostQuitMessage (0);
        break;
        
        case WM_PAINT:
        {
            PAINTSTRUCT ps;
            HDC hdc = BeginPaint (hwnd, &ps);
            TextOutA (hdc,
                     // Location of the text
                     10,
                     10,
                     // Text to print
                     TextArray [0],
                     // Size of the text, my function gets this for us
                     GetTextSize (TextArray [0]));
            EndPaint (hwnd, &ps);
        }
        break;
    }
    return DefWindowProc (hwnd, msg, wParam, lParam);
}

int WINAPI WinMain (HINSTANCE hInstanace, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    WNDCLASSEX WindowClass;
    WindowClass.cbClsExtra = 0;
    WindowClass.cbWndExtra = 0;
    WindowClass.cbSize = sizeof (WNDCLASSEX);
    WindowClass.lpszClassName = "1";
    WindowClass.lpszMenuName = NULL;
    WindowClass.lpfnWndProc = WndProc;
    WindowClass.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    WindowClass.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    WindowClass.hCursor = LoadCursor (NULL, IDC_ARROW);
    WindowClass.style = 0;
    WindowClass.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
    RegisterClassEx (&WindowClass);

    HWND hwnd = CreateWindowEx (WS_EX_CLIENTEDGE,
                                "1",
                                "Printing Text in Win32 C/C++",
                                WS_OVERLAPPEDWINDOW,
                                315, 115,
                                640, 480,
                                NULL,
                                NULL,
                                hInstance,
                                NULL);

    ShowWindow (hwnd, SW_SHOWNORMAL);

    MSG msg;

    while (GetMessage (&msg, NULL, 0, 0) > 0)
    {
        TranslateMessage (&msg);
        DispatchMessage (&msg);
        if (VK_ESCAPE == msg.wParam)
            break;
    }
    return 0;
}

is that normal ?
Find all posts by this user
Quote this message in a reply
01-09-2019, 08:16 AM
Post: #24
RE: Hello Ed -2!
Ed
If is not problem
Do you can try this examples in Falcon C++ ide
Find all posts by this user
Quote this message in a reply
01-09-2019, 10:05 PM
Post: #25
RE: Hello Ed -2!
(01-09-2019 03:23 AM)Aurel Wrote:  Ed
Just to let you know your example return error
" unreferenced TextOutA@'20 "
what kind of error is that ????

It compiles fine here with MingW:

gcc -mwindows winau.c

Creates "a.exe".

The error you are getting is a linker error. TextOut is a unicode/ansi function, and depending on how you have unicode set, it tries to link with either TextOutW (for wide char) or TextOutA (for ansi).

No idea why your linker can't find it.

I also tried Borland C, and it worked fine with that too.

Did your original version compile?
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: