Load .txt file with resurce

Working to same project an MDI and now I have to load some text files to my child window, that handles a static control. So I know how to add a bitmap to a static, but I was asking if the same thing working with a text file..?

Can anyone give me a hand.. will be so kind if will be a concrete answer like with show me the right path and how to handle a message inside a static, without any internet links ? maybe an example how it should look like ?

If part of the code needed i can put it right away... like my static control

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
LRESULT CALLBACK MDIChildWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch(msg)
    {
    case WM_CREATE:
        {
            // Create Static control
            HFONT hfDefault;
            HWND hStatic1;

            hStatic1 = CreateWindowEx(WS_EX_CLIENTEDGE, "static", NULL,
                                      WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
                                      0, 0, 100, 100, hwnd, (HMENU)IDC_CHILD_STATIC1,
                                      GetModuleHandle(NULL), NULL);

            if(hStatic1 == NULL)
            {
                MessageBox(hwnd, "Could not create Static control !", "Error",
                           MB_ICONERROR | MB_OK);
            }

            hfDefault = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
            SendMessage(hStatic1, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
        }
Last edited on
I'm not sure what you're asking?

Maybe SetWindowText is what you're looking for? See:

https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowtexta
No no... If you have a project and in the same folder you have an example.txt file. Then you have an MDI which you have a menu and menu items and let's say one of this menu item is called example. then you load the example.txt from the folder with resurce.rc in to your child widow and show that text in a static window which the child window is holding.
Topic archived. No new replies allowed.