Menu

How do I change "Windows BGI" Window Title?

2004-04-22
2012-09-26
  • Nobody/Anonymous

    This might be easy, but I can't seem to find where I can set or change this. I tried in winbgim.cpp, but I still get a Window with "Windows BGI" as the title.

    -David

     
    • Nobody/Anonymous

      Can you post the code?

      JMan

       
    • Anonymous

      Anonymous - 2004-04-22

      You can change the title in the winbgim.cpp sourcecode (the CreateWindow function), but normally you link the the libbgi.a file, so you need to use your modified winbgim.cpp file to rebuild the static library.

      An easier and more flexible method is to use the Win32 API SetWindowText() function:http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowfunctions/setwindowtext.asp.

      Clifford.

       
    • Nobody/Anonymous

      Here is my code

      I can't seem to change the title from "Windows BGI" to "My Window".

      #include <winbgim.h>
      #include <windows.h>

      static HWND hWnd;

      int main()
      {
        cleardevice();
        initwindow(320,240);
        SetWindowText(hWnd, "My Window");
        int x =0;
        int y =0;
      while (!kbhit() && y <=240 )
      {
         putpixel(x,y,2);
         Sleep(100);
         x++;
         y++;
      }
      return 0;
      }

       
    • Nobody/Anonymous

      I am the OP and I found a fix. I think it can also be used to change the title of any Window.

      Thanks for all the help...

      -David

      Fix follows

      #include <winbgim.h>
      #include <windows.h>

      int main()
      {
        cleardevice();
        initwindow(320,240);
        HWND hWnd, hWndChild;
        hWnd = FindWindow(NULL, "Windows BGI");
        hWndChild = GetWindow(hWnd, GW_CHILD);
        SendMessage((HWND) hWnd, WM_SETTEXT,0, (LPARAM)"My Window");
        int x =0;
        int y =0;
          while (!kbhit() && y <=240 )
           {
              putpixel(x,y,2);
              Sleep(100);
              x++;
              y++;
           }
        return 0;
      }

       
    • Anonymous

      Anonymous - 2004-04-23

      In the first instance you declared a window handle, but never set it to anything. Your second code will work. I cannot find an alternative approach to getting the Window handle. However I'd be tempted to add an access function to the winbgim sourcecode to return the static hWnd that it holds. This would of course require you to re-build the library.

      Clifford.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.