Results 1 to 13 of 13

Thread: two quick questions...

  1. #1

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091

    Smile two quick questions...

    Is there a way to change the style of an Edit box from just a vertical scrollbar, to a vertical and horizontal scrollbar? I've tried using SetWindowLong, but it doesn't seem to work. Or do I need two Edit boxes?

    And, is there a way to check if the clipboard is empty, or if it contains data other than regular text? I've read a little about using the clipboard, but can't seem to find what I am looking for

    Thanks
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  2. #2
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    1: Do you want to change the numbes of scrollbar at runtime (I mean after you have create the edit boxes)?

    2: Try this API call:

    bAvailable = IsClipboardFormatAvailable (CF_TEXT) ;

    if bAvailable equals true then you have some kinds of text in the clipboard
    Baaaaaaaaah

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    To add a second scrollbar at creation time, specify the WS_HSCROLL style (i guess you know that)
    To do it at runtime, call
    Code:
    SetWindowLong(GWL_STYLE, GetWindowLong(GWL_STYLE) | WS_HSCROLL);
    
    // to remove the scroll bar
    SetWindowLong(GWL_STYLE, GetWindowLong(GWL_STYLE) & !WS_HSCROLL);
    if that doesn't work, I don't think there is a way.

    All the buzzt
    CornedBee

  4. #4
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    2.
    Have a look at theis API's
    Code:
    CountClipboardFormats
    The CountClipboardFormats function retrieves the number of different data formats currently on the clipboard. 
    
    int CountClipboardFormats(VOID)
    Code:
    GetClipboardFormatName
    The GetClipboardFormatName function retrieves from the clipboard the name of the specified registered format. The function copies the name to the specified buffer. 
    
    int GetClipboardFormatName(
      UINT format,            // clipboard format to retrieve
      LPTSTR lpszFormatName,  // address of buffer for name
      int cchMaxCount         // length of name string in characters
    );
     
    Parameters
    format 
    Specifies the type of format to be retrieved. This parameter must not specify any of the predefined clipboard formats. 
    lpszFormatName 
    Pointer to the buffer that is to receive the format name. 
    cchMaxCount 
    Specifies the maximum length, in characters, of the string to be copied to the buffer. If the name exceeds this limit, it is truncated.
    Code:
    GetClipboardData
    The GetClipboardData function retrieves data from the clipboard in a specified format. The clipboard must have been opened previously. 
    
    HANDLE GetClipboardData(
      UINT uFormat   // clipboard format
    );
     
    Parameters
    uFormat 
    Specifies a clipboard format. For a description of the standard clipboard formats, see Standard Clipboard Formats. 
    Return Values
    If the function succeeds, the return value is the handle of a clipboard object in the specified format.
    
    If the function fails, the return value is NULL. To get extended error information, call GetLastError.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  5. #5

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Well, all the Clipboard code works. Thanks a lot

    But the scrollbars code doesn't appear to do anything

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  6. #6
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    You also need to provide the handle to the edit control in order to set the scrollbars.

    Try this:

    PHP Code:
    SetWindowLong(HWND_OF_EDITCONTROLGWL_STYLEGetWindowLong(HWND_OF_EDITCONTROLGWL_STYLE)  |  WS_HSCROLL); 
    Baaaaaaaaah

  7. #7

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    nope, still nothing. I figured I needed to pass the hwnd when it wouldn't compile.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  8. #8
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Have you provided the style "ES_WANTRETURN"? If yes then remove it if you want to see the horizontal scrollbar
    Baaaaaaaaah

  9. #9

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    okay, a step in the right direction. The horizontal scroll bar shows up but it still wraps the text. Here is my code:
    PHP Code:
    void SetWordWrap()
    {

        if(
    bWordWrap)
        {
            
    SetWindowLong(ghWnd_Main_EditGWL_STYLEGetWindowLong(ghWnd_Main_Edit,GWL_STYLE) | WS_HSCROLL & !ES_WANTRETURN);
            
    ShowScrollBar(ghWnd_Main_EditSB_BOTHtrue);
        }
        else
        {
            
    SetWindowLong(ghWnd_Main_EditGWL_STYLEGetWindowLong(ghWnd_Main_Edit,GWL_STYLE) | !WS_HSCROLL ES_WANTRETURN);
            
    ShowScrollBar(ghWnd_Main_EditSB_HORZfalse);
        }

        
    bWordWrap = !bWordWrap;

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  10. #10
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Try this:

    PHP Code:
    void SetWordWrap()
    {

        if(
    bWordWrap)
        {
            
    SetWindowLong(ghWnd_Main_EditGWL_STYLEGetWindowLong(ghWnd_Main_Edit,GWL_STYLE) | WS_HSCROLL | !ES_WANTRETURN);
            
    ShowScrollBar(ghWnd_Main_EditSB_BOTHtrue);
        }
        else
        {
            
    SetWindowLong(ghWnd_Main_EditGWL_STYLEGetWindowLong(ghWnd_Main_Edit,GWL_STYLE) | !WS_HSCROLL ES_WANTRETURN);
            
    ShowScrollBar(ghWnd_Main_EditSB_HORZfalse);
        }

        
    bWordWrap = !bWordWrap;

    Baaaaaaaaah

  11. #11

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    with that code the hscroll does appear at all

    Thanks, though.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  12. #12
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    What do you really want to do in general? Not just showing, hiding a horizontal scrollbar.
    Baaaaaaaaah

  13. #13
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    maybe this works:
    PHP Code:
    void SetWordWrap()
    {

        if(
    bWordWrap)
        {
            
    SetWindowLong(ghWnd_Main_EditGWL_STYLEGetWindowLong(ghWnd_Main_Edit,GWL_STYLE) | WS_HSCROLL ES_AUTOHSCROLL & !ES_WANTRETURN);
            
    ShowScrollBar(ghWnd_Main_EditSB_BOTHtrue);
        }
        else
        {
            
    SetWindowLong(ghWnd_Main_EditGWL_STYLEGetWindowLong(ghWnd_Main_Edit,GWL_STYLE) & !WS_HSCROLL & !ES_AUTOHSCROLL ES_WANTRETURN);
            
    ShowScrollBar(ghWnd_Main_EditSB_HORZfalse);
        }

        
    bWordWrap = !bWordWrap;

    If you want to remove a style, use & !STYLE
    if you want to add one, use | STYLE

    You also have to add the ES_AUTOHSCROLL style if the edit box should not wrap the words.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width