user1417643
user1417643

Reputation: 11

simple windows c++ not visible

case WM_CREATE:
    {
    int randomsize=0;
    //std::string lineofquote;
    char lineofquote[255];
    std::ifstream infile;
    infile.open("quotes.txt",std::ios::in);
    if (infile)
    {
        MessageBox(NULL,"infile failed","Error reading file", MB_OK);
        return 0;
    }
    newhandler = CreateWindow(TEXT("static"),TEXT("Quote here") ,WS_CHILD | WS_VISIBLE , 0,0,550,150,hWnd,NULL,NULL,NULL);

    while(!infile.eof())//get file size
    {
        infile.getline(lineofquote,255,'\n');
        SetWindowText(newhandler,lineofquote);
        randomsize++;
    }
    infile.close();
    //std::cout<<randomsize;

    break;
    }

When i run this program, i dont seem to see my windows at all. What might be the problem here?

Upvotes: 0

Views: 716

Answers (2)

Ufo
Ufo

Reputation: 225

Check your ShowWindow() function. You could set CmdShow parameter to 0 which means that your window will not be visible, or just simply you forgot to call this function. Also, you could check if RegisterClassEx(...) worked propely.

Upvotes: 1

UltraInstinct
UltraInstinct

Reputation: 44454

That is not the way you create a window. You create a window using CreateWindow API. There are a couple of things you need to do along with it. May be this MSDN tutorial can help.

WM_CREATE is an event fired when a window is created, typically using the above API.

Always read the documentation properly. As long as you are dealing with Win32 APIs, MSDN will be your bible.

Upvotes: 1

Related Questions