Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how to change window's start button text? problem with my program

how to change window's start button text? problem with my program

Scheduled Pinned Locked Moved C / C++ / MFC
c++linuxhelptutorialquestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    ELY M
    wrote on last edited by
    #1

    Im using MFC to make dailog based program. I have one button that will change my start button text to "TEST" after click. my program crash after I clicked on the button here is the code for the button. void CStart_Button_ChangerDlg::OnText() { HWND starthandle; CWnd StartButton; CWnd* Window = CWnd::FindWindow("Shell_TrayWnd",""); starthandle = FindWindowEx(NULL,NULL,"Button",""); StartButton.m_hWnd=starthandle; StartButton.SetWindowText("TEST"); StartButton.SendMessage(WM_SETTEXT,0,0); //SendMessage (StartButton, WM_SETTEXT, 0); }

    RaviBeeR D 2 Replies Last reply
    0
    • E ELY M

      Im using MFC to make dailog based program. I have one button that will change my start button text to "TEST" after click. my program crash after I clicked on the button here is the code for the button. void CStart_Button_ChangerDlg::OnText() { HWND starthandle; CWnd StartButton; CWnd* Window = CWnd::FindWindow("Shell_TrayWnd",""); starthandle = FindWindowEx(NULL,NULL,"Button",""); StartButton.m_hWnd=starthandle; StartButton.SetWindowText("TEST"); StartButton.SendMessage(WM_SETTEXT,0,0); //SendMessage (StartButton, WM_SETTEXT, 0); }

      RaviBeeR Offline
      RaviBeeR Offline
      RaviBee
      wrote on last edited by
      #2

      This[^] article may help. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

      1 Reply Last reply
      0
      • E ELY M

        Im using MFC to make dailog based program. I have one button that will change my start button text to "TEST" after click. my program crash after I clicked on the button here is the code for the button. void CStart_Button_ChangerDlg::OnText() { HWND starthandle; CWnd StartButton; CWnd* Window = CWnd::FindWindow("Shell_TrayWnd",""); starthandle = FindWindowEx(NULL,NULL,"Button",""); StartButton.m_hWnd=starthandle; StartButton.SetWindowText("TEST"); StartButton.SendMessage(WM_SETTEXT,0,0); //SendMessage (StartButton, WM_SETTEXT, 0); }

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        Mouse_103 wrote: ...change my start button text to "TEST"... See here on how to do this. Mouse_103 wrote: starthandle = FindWindowEx(NULL,NULL,"Button",""); StartButton.SetWindowText("TEST"); Should be:

        starthandle = FindWindowEx(Window->GetSafeHwnd(),NULL,"Button",NULL);
        ::SetWindowText(starthandle, "TEST");

        However, this will not work as intended as the Start button's text is not drawn in the normal fashion.


        "Ideas are a dime a dozen. People who put them into action are priceless." - Unknown

        E 1 Reply Last reply
        0
        • D David Crow

          Mouse_103 wrote: ...change my start button text to "TEST"... See here on how to do this. Mouse_103 wrote: starthandle = FindWindowEx(NULL,NULL,"Button",""); StartButton.SetWindowText("TEST"); Should be:

          starthandle = FindWindowEx(Window->GetSafeHwnd(),NULL,"Button",NULL);
          ::SetWindowText(starthandle, "TEST");

          However, this will not work as intended as the Start button's text is not drawn in the normal fashion.


          "Ideas are a dime a dozen. People who put them into action are priceless." - Unknown

          E Offline
          E Offline
          ELY M
          wrote on last edited by
          #4

          --------------------Configuration: Start_Button_Changer - Win32 Debug-------------------- Compiling... Start_Button_ChangerDlg.cpp C:\-= My Stuff =-\Start_Button_Changer\Start_Button_ChangerDlg.cpp(186) : error C2660: 'SetWindowTextA' : function does not take 2 parameters Error executing cl.exe. Start_Button_Changer.exe - 1 error(s), 0 warning(s)

          D 1 Reply Last reply
          0
          • E ELY M

            --------------------Configuration: Start_Button_Changer - Win32 Debug-------------------- Compiling... Start_Button_ChangerDlg.cpp C:\-= My Stuff =-\Start_Button_Changer\Start_Button_ChangerDlg.cpp(186) : error C2660: 'SetWindowTextA' : function does not take 2 parameters Error executing cl.exe. Start_Button_Changer.exe - 1 error(s), 0 warning(s)

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            The compiler is telling you exactly what the problem is. You are trying to use CWnd::SetWindowText() which does not take 2 parameters.


            "Ideas are a dime a dozen. People who put them into action are priceless." - Unknown

            E 1 Reply Last reply
            0
            • D David Crow

              The compiler is telling you exactly what the problem is. You are trying to use CWnd::SetWindowText() which does not take 2 parameters.


              "Ideas are a dime a dozen. People who put them into action are priceless." - Unknown

              E Offline
              E Offline
              ELY M
              wrote on last edited by
              #6

              I got it working now now Im trying to get working with the user defined edit box. I use control CEdit for the edit box. void CStart_Button_ChangerDlg::OnText() { HWND hWnd; RECT rc; if (hWnd = FindWindowEx(NULL, NULL, "Shell_TrayWnd", NULL)) { ::GetWindowRect(hWnd, &rc); if (hWnd = FindWindowEx(hWnd, NULL, "Button", NULL)) { /* CEdit* text = (CEdit*)GetDlgItem(IDC_EDIT1); CString gettext; text->GetWindowText(gettext); */ CString starttext; m_text.GetWindowText(starttext); ::SendMessage(hWnd, WM_SETTEXT, 0, (LPARAM)(LPTSTR) TEXT(starttext)); } } } compile error: Compiling... Start_Button_ChangerDlg.cpp C:\-= My Stuff =-\Start_Button_Changer2\Start_Button_ChangerDlg.cpp(199) : error C2440: 'type cast' : cannot convert from 'class CString' to 'char *' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called Error executing cl.exe. Start_Button_Changer.exe - 1 error(s), 0 warning(s)

              E 1 Reply Last reply
              0
              • E ELY M

                I got it working now now Im trying to get working with the user defined edit box. I use control CEdit for the edit box. void CStart_Button_ChangerDlg::OnText() { HWND hWnd; RECT rc; if (hWnd = FindWindowEx(NULL, NULL, "Shell_TrayWnd", NULL)) { ::GetWindowRect(hWnd, &rc); if (hWnd = FindWindowEx(hWnd, NULL, "Button", NULL)) { /* CEdit* text = (CEdit*)GetDlgItem(IDC_EDIT1); CString gettext; text->GetWindowText(gettext); */ CString starttext; m_text.GetWindowText(starttext); ::SendMessage(hWnd, WM_SETTEXT, 0, (LPARAM)(LPTSTR) TEXT(starttext)); } } } compile error: Compiling... Start_Button_ChangerDlg.cpp C:\-= My Stuff =-\Start_Button_Changer2\Start_Button_ChangerDlg.cpp(199) : error C2440: 'type cast' : cannot convert from 'class CString' to 'char *' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called Error executing cl.exe. Start_Button_Changer.exe - 1 error(s), 0 warning(s)

                E Offline
                E Offline
                ELY M
                wrote on last edited by
                #7

                never mind I got it working... I had to change the LPTSTR to LPCTSTR

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups