0

Hello! I'm having a slight problem with a event... What I'm basically trying to do is:
Activate a on button event, that fetches source code, then posts it within the edit window with "SetWindowText(hTextBox, get_source("website", "path"));".

Sadly, this didn't quite work out that well, as I recieve a Run- Time Check Failure, "The variable "hTextBox" is being use without being initialized.". I tried assigning NULL to the objects; it silenced the error, but no apparent side-effect(s).

Note: "SetWindowText(hTextBox, get_source("website", "path"));", works perfectly, if I place it in the WM_CREATE event.

Any ideas?

LRESULT CALLBACK WndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
    HWND hTextBox = NULL, hButtonGet = NULL, hButtonQuit = NULL;
    HINSTANCE hInst = GetModuleHandle(NULL);
    switch (msg) {
    case WM_CREATE:
        hTextBox = CreateWindowExW(WS_EX_CLIENTEDGE, L"EDIT", NULL, WS_CHILD|WS_VISIBLE|WS_VSCROLL|WS_HSCROLL|ES_MULTILINE|ES_AUTOVSCROLL, 7, 35, 300, 200, hwnd, NULL, hInst, NULL);
        hButtonGet = CreateWindowEx(NULL, "BUTTON", "Get Source", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 10, 250, 100, 25, hwnd, (HMENU)IDC_BUTTON_GET, hInst, NULL);
        hButtonQuit = CreateWindowEx(NULL, "BUTTON", "Quit", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 130, 250, 100, 25, hwnd, (HMENU)IDC_BUTTON_QUIT, hInst, NULL);
        //SetWindowText(hTextBox, get_source("www.mznation.com", "/beta/index.php"));
        break;
    case WM_COMMAND:
        switch (LOWORD(wParam)) {
        case IDC_BUTTON_GET:
            SetWindowText(hTextBox, get_source("www.mznation.com", "/index.php"));
            break;
        case IDC_BUTTON_QUIT:
            DestroyWindow(hwnd);
            break;
        }
        break;
    case WM_CLOSE:
        DestroyWindow(hwnd);
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hwnd, msg, wParam, lParam);
    }
    return 0;
}
2
Contributors
1
Reply
3
Views
4 Years
Discussion Span
Last Post by BobS0327
0

Could the problem possibly be that you're using two different paths in your get_source function and the path is WM_CREATE is valid but the path in the case statement IDC_BUTTON_GET is invalid.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.