Menu

(WinAPI) Updating a var used in a control

2002-11-25
2012-09-26
  • Nobody/Anonymous

    If a windows control is created like that:

    ...
    char* infoText = ("Some text.");
    ...
    case WM_CREATE:
    infoText = CreateWindow (TEXT ("edit"), TEXT(infotext), WS_CHILD | WS_VISIBLE | ES_MULTILINE | WS_VSCROLL, 10, 35, 320, 135, hWndMain, (HMENU) 10, ((LPCREATESTRUCT) lParam)->hInstance, NULL) ;
    break;

    And then, in other point of my app, i set another value to var infoText, will the control automatically display the new content or do i have to send a message to that control to update with the new content or maybe i have to call WM_CREATE again, whats the right way to do it?  

    /Clamer          

     
    • Nobody/Anonymous

      And one more question:
      I want to do something like:
      CASE The_Focus_Has_Changed_From_One_Control_To_Other:
      {
      stuff
      }

      Is it possible?

       
    • Nobody/Anonymous

      Changing the content of infoText (with another CreateWindow) will not cause the previous control to disappear. It will only load another window handle into infoText.
      A simple hack: Create the necessary controls on top of each other and make them invisible except the one you need at a given time.

      The second one: sure it is possible, there are standard windows messages indicating when a control gains or lost focus. See win32.hlp.
      (I don't keep such things ready in my little head, sorry).

      rpeter

       
    • Nobody/Anonymous

      Hi, I've work with Borland C++ 5 for a long and I know a little deep all the tree classes for Windows. If a wan't to use the Win API in Dev-cpp I must to learn the win32 api. (Borland had created classes to work with win32 api.) I don't want to do the all job again. Is any way to use the borland C++ classes in dev-cpp ?
      Esteban

       
    • Nobody/Anonymous

      if you want to update the control ill say

      SendMessage(10, WM_SETTEXT, len + 1, (LPARAM)(LPSTR)infoText);

      or
      SendMessage(10,  EM_SETSEL, len + 1, (LPARAM)(LPSTR)infoText);

      that is probably what you would use to add text to a edit control. too  up date the control like append text use EM_REPLACESEL, may have to include richedit.h for implementation

       

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.