-
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
:)
-
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
-
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
-
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.
-
Well, all the Clipboard code works. Thanks a lot :D
But the scrollbars code doesn't appear to do anything
:)
-
You also need to provide the handle to the edit control in order to set the scrollbars.
Try this:
PHP Code:
SetWindowLong(HWND_OF_EDITCONTROL, GWL_STYLE, GetWindowLong(HWND_OF_EDITCONTROL, GWL_STYLE) | WS_HSCROLL);
-
nope, still nothing. I figured I needed to pass the hwnd when it wouldn't compile.
-
Have you provided the style "ES_WANTRETURN"? If yes then remove it if you want to see the horizontal scrollbar
-
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_Edit, GWL_STYLE, GetWindowLong(ghWnd_Main_Edit,GWL_STYLE) | WS_HSCROLL & !ES_WANTRETURN);
ShowScrollBar(ghWnd_Main_Edit, SB_BOTH, true);
}
else
{
SetWindowLong(ghWnd_Main_Edit, GWL_STYLE, GetWindowLong(ghWnd_Main_Edit,GWL_STYLE) | !WS_HSCROLL & ES_WANTRETURN);
ShowScrollBar(ghWnd_Main_Edit, SB_HORZ, false);
}
bWordWrap = !bWordWrap;
}
-
Try this:
PHP Code:
void SetWordWrap()
{
if(bWordWrap)
{
SetWindowLong(ghWnd_Main_Edit, GWL_STYLE, GetWindowLong(ghWnd_Main_Edit,GWL_STYLE) | WS_HSCROLL | !ES_WANTRETURN);
ShowScrollBar(ghWnd_Main_Edit, SB_BOTH, true);
}
else
{
SetWindowLong(ghWnd_Main_Edit, GWL_STYLE, GetWindowLong(ghWnd_Main_Edit,GWL_STYLE) | !WS_HSCROLL | ES_WANTRETURN);
ShowScrollBar(ghWnd_Main_Edit, SB_HORZ, false);
}
bWordWrap = !bWordWrap;
}
-
with that code the hscroll does appear at all :(
Thanks, though.
-
What do you really want to do in general? Not just showing, hiding a horizontal scrollbar.
-
maybe this works:
PHP Code:
void SetWordWrap()
{
if(bWordWrap)
{
SetWindowLong(ghWnd_Main_Edit, GWL_STYLE, GetWindowLong(ghWnd_Main_Edit,GWL_STYLE) | WS_HSCROLL | ES_AUTOHSCROLL & !ES_WANTRETURN);
ShowScrollBar(ghWnd_Main_Edit, SB_BOTH, true);
}
else
{
SetWindowLong(ghWnd_Main_Edit, GWL_STYLE, GetWindowLong(ghWnd_Main_Edit,GWL_STYLE) & !WS_HSCROLL & !ES_AUTOHSCROLL | ES_WANTRETURN);
ShowScrollBar(ghWnd_Main_Edit, SB_HORZ, false);
}
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.