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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Working With Edit Control

Working With Edit Control

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
13 Posts 5 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.
  • S Offline
    S Offline
    Suresh H
    wrote on last edited by
    #1

    Hello all, I have one Edit Control IDC_PATH , and some path in (LPARAM)szDir variable. Now I want to set the value of szDir in the IDC_PATH edit box , how to do this ?? Please can anyone tell me hw to do this . SendDlgItemMessage(hwnd,IDC_PATH,(LPARAM)szDir,0,0); I tried with this code its not working. What will be the error ? Edit/Delete Message And also I want to know how to disable and enable edit box ??? Thanking you, Suresh HC.

    J P C 3 Replies Last reply
    0
    • S Suresh H

      Hello all, I have one Edit Control IDC_PATH , and some path in (LPARAM)szDir variable. Now I want to set the value of szDir in the IDC_PATH edit box , how to do this ?? Please can anyone tell me hw to do this . SendDlgItemMessage(hwnd,IDC_PATH,(LPARAM)szDir,0,0); I tried with this code its not working. What will be the error ? Edit/Delete Message And also I want to know how to disable and enable edit box ??? Thanking you, Suresh HC.

      J Offline
      J Offline
      Jetli Jerry
      wrote on last edited by
      #2

      Suresh H wrote:

      SendDlgItemMessage(hwnd,IDC_PATH,(LPARAM)szDir,0,0);

      SetDlgItemText(IDC_PATH,szDir); should do hth

      Jetli Constant Thing In World Is Change.

      S 1 Reply Last reply
      0
      • J Jetli Jerry

        Suresh H wrote:

        SendDlgItemMessage(hwnd,IDC_PATH,(LPARAM)szDir,0,0);

        SetDlgItemText(IDC_PATH,szDir); should do hth

        Jetli Constant Thing In World Is Change.

        S Offline
        S Offline
        Suresh H
        wrote on last edited by
        #3

        Hi Jetli, Thanks for the responce. I tryed with that code i am getting error SetDlgItemText(IDC_PATH,szDir); error C2660: 'SetDlgItemTextA' : function does not take 2 parameters Error executing cl.exe.

        J 1 Reply Last reply
        0
        • S Suresh H

          Hi Jetli, Thanks for the responce. I tryed with that code i am getting error SetDlgItemText(IDC_PATH,szDir); error C2660: 'SetDlgItemTextA' : function does not take 2 parameters Error executing cl.exe.

          J Offline
          J Offline
          jk chan
          wrote on last edited by
          #4

          Which type is your application ? if it is a MFC dialg based app the paramter to SetDlgItemText is correct , otherwise u need to provide the HWND of your dialog in SetDlgItemText function. SetDlgItemText( , IDC_PATH, szDir); Refer MSDN.

          If u can Dream... U can do it

          S 1 Reply Last reply
          0
          • J jk chan

            Which type is your application ? if it is a MFC dialg based app the paramter to SetDlgItemText is correct , otherwise u need to provide the HWND of your dialog in SetDlgItemText function. SetDlgItemText( , IDC_PATH, szDir); Refer MSDN.

            If u can Dream... U can do it

            S Offline
            S Offline
            Suresh H
            wrote on last edited by
            #5

            Hi krishna, I am using Win 32 Application.

            J 1 Reply Last reply
            0
            • S Suresh H

              Hi krishna, I am using Win 32 Application.

              J Offline
              J Offline
              jk chan
              wrote on last edited by
              #6

              So where you placed the edit control ? dialog or window ? and which function you using for showing dialog(DialogBox() ) ? you will get the hwnd of dialog in dialog Proc. if it is dialog put your dialogs handle in SetDlgItemText Hopes this helps

              If u can Dream... U can do it

              1 Reply Last reply
              0
              • S Suresh H

                Hello all, I have one Edit Control IDC_PATH , and some path in (LPARAM)szDir variable. Now I want to set the value of szDir in the IDC_PATH edit box , how to do this ?? Please can anyone tell me hw to do this . SendDlgItemMessage(hwnd,IDC_PATH,(LPARAM)szDir,0,0); I tried with this code its not working. What will be the error ? Edit/Delete Message And also I want to know how to disable and enable edit box ??? Thanking you, Suresh HC.

                P Offline
                P Offline
                prasad_som
                wrote on last edited by
                #7

                Suresh H wrote:

                SendDlgItemMessage(hwnd,IDC_PATH,(LPARAM)szDir,0,0);

                You passing wrong value as third parameter, it should be message to send(WM_SETTEXT in this case). Modify your code to,

                SendDlgItemMessage(hwnd,IDC_PATH,WM_SETTEXT,0,(LPARAM)szDir);

                You can use SetDlgItemText either.

                Prasad Notifier using ATL | Operator new[],delete[][^]

                S 1 Reply Last reply
                0
                • S Suresh H

                  Hello all, I have one Edit Control IDC_PATH , and some path in (LPARAM)szDir variable. Now I want to set the value of szDir in the IDC_PATH edit box , how to do this ?? Please can anyone tell me hw to do this . SendDlgItemMessage(hwnd,IDC_PATH,(LPARAM)szDir,0,0); I tried with this code its not working. What will be the error ? Edit/Delete Message And also I want to know how to disable and enable edit box ??? Thanking you, Suresh HC.

                  C Offline
                  C Offline
                  CPallini
                  wrote on last edited by
                  #8

                  Change

                  Suresh H wrote:

                  SendDlgItemMessage(hwnd,IDC_PATH,(LPARAM)szDir,0,0);

                  To

                  SendDlgItemMessage(hwnd,IDC_PATH, WM_SETTEXT, 0, (LPARAM)szDir);

                  Suresh H wrote:

                  And also I want to know how to disable and enable edit box ???

                  use:

                  BOOL EnableWindow(
                  HWND hWnd, // handle to window
                  BOOL bEnable // flag for enabling or disabling input
                  );

                  If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

                  S 1 Reply Last reply
                  0
                  • P prasad_som

                    Suresh H wrote:

                    SendDlgItemMessage(hwnd,IDC_PATH,(LPARAM)szDir,0,0);

                    You passing wrong value as third parameter, it should be message to send(WM_SETTEXT in this case). Modify your code to,

                    SendDlgItemMessage(hwnd,IDC_PATH,WM_SETTEXT,0,(LPARAM)szDir);

                    You can use SetDlgItemText either.

                    Prasad Notifier using ATL | Operator new[],delete[][^]

                    S Offline
                    S Offline
                    Suresh H
                    wrote on last edited by
                    #9

                    Hi Prasad, Its working thank you very much.

                    P 1 Reply Last reply
                    0
                    • S Suresh H

                      Hi Prasad, Its working thank you very much.

                      P Offline
                      P Offline
                      prasad_som
                      wrote on last edited by
                      #10

                      Most welcome ! :) Actually , I overseen your second question. But CPallini has answered that.

                      Prasad Notifier using ATL | Operator new[],delete[][^]

                      1 Reply Last reply
                      0
                      • C CPallini

                        Change

                        Suresh H wrote:

                        SendDlgItemMessage(hwnd,IDC_PATH,(LPARAM)szDir,0,0);

                        To

                        SendDlgItemMessage(hwnd,IDC_PATH, WM_SETTEXT, 0, (LPARAM)szDir);

                        Suresh H wrote:

                        And also I want to know how to disable and enable edit box ???

                        use:

                        BOOL EnableWindow(
                        HWND hWnd, // handle to window
                        BOOL bEnable // flag for enabling or disabling input
                        );

                        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

                        S Offline
                        S Offline
                        Suresh H
                        wrote on last edited by
                        #11

                        Hi Pallini , Thank you very much its working. I did not understand how to enable and disable the edit box. Can u please tell me how to disable the edit box IDC_PATH ?

                        P 1 Reply Last reply
                        0
                        • S Suresh H

                          Hi Pallini , Thank you very much its working. I did not understand how to enable and disable the edit box. Can u please tell me how to disable the edit box IDC_PATH ?

                          P Offline
                          P Offline
                          prasad_som
                          wrote on last edited by
                          #12

                          Suresh H wrote:

                          Can u please tell me how to disable the edit box IDC_PATH ?

                          HWND hEdit = GetDlgItem(hDlg,IDC_PATH);//hDlg handle to dialog
                          EnableWindow(hEdit,FALSE);//disables window
                          and
                          EnableWindow(hEdit,TRUE);//enables window

                          Prasad Notifier using ATL | Operator new[],delete[][^]

                          S 1 Reply Last reply
                          0
                          • P prasad_som

                            Suresh H wrote:

                            Can u please tell me how to disable the edit box IDC_PATH ?

                            HWND hEdit = GetDlgItem(hDlg,IDC_PATH);//hDlg handle to dialog
                            EnableWindow(hEdit,FALSE);//disables window
                            and
                            EnableWindow(hEdit,TRUE);//enables window

                            Prasad Notifier using ATL | Operator new[],delete[][^]

                            S Offline
                            S Offline
                            Suresh H
                            wrote on last edited by
                            #13

                            Hi Prasad, Thank you once again its working.

                            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