|
-
Aug 27th, 2001, 04:51 PM
#1
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
-
Aug 28th, 2001, 12:38 AM
#2
PowerPoster
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
-
Aug 28th, 2001, 03:06 AM
#3
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
-
Aug 28th, 2001, 08:20 AM
#4
Frenzied Member
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.
-
Aug 28th, 2001, 03:14 PM
#5
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
-
Aug 28th, 2001, 03:33 PM
#6
PowerPoster
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);
-
Aug 28th, 2001, 03:36 PM
#7
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
-
Aug 28th, 2001, 03:39 PM
#8
PowerPoster
Have you provided the style "ES_WANTRETURN"? If yes then remove it if you want to see the horizontal scrollbar
-
Aug 28th, 2001, 03:48 PM
#9
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;
}
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Aug 28th, 2001, 03:55 PM
#10
PowerPoster
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;
}
-
Aug 28th, 2001, 04:09 PM
#11
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
-
Aug 28th, 2001, 05:22 PM
#12
PowerPoster
What do you really want to do in general? Not just showing, hiding a horizontal scrollbar.
-
Aug 29th, 2001, 02:00 AM
#13
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|