|
1.first, take a separate application for test.
2.take two list controls.
3.in properties, enable sort for one control.
4.assign a member variables to both.(say m_l1,m_l2)
5.try m_l1.GetProperty() and m_l2.GetProperty();
6.see the difference.
7.then appply the same for the required control using SetProperty();
|
|
|
|
|
I've seen various applications that run on Windows detect the upload speed of data being transfered upstream. Obviously this can be done through some feature in Winsock that I can't seem to find. I can do a send() on a non-blocking socket of 1MB of data and it returns immediately and successfully but I know the data is just queued and being sent at about 40K/sec. How? What API?
Actually, never mind. I'm pretty sure I've figured it out.
-- modified at 3:20 Monday 3rd September, 2007
|
|
|
|
|
IsDestinationReachable() AIP helps?
|
|
|
|
|
I forgot to mention that I'd like to remain as cross-platform portable as possible (Preference: BSD-style socket calls) and also something that works under NT 4 (Win9x support would be nice but not necessary) and the language I'm using is C++.
The IsDestinationReachable() API is not useful. It just returns the line speed of my Ethernet connection (100Mbps).
|
|
|
|
|
Hello Friends,
Can I change the color of Button Caption.
I am using Win32 Appliction. And I have a Button on Dialog Box, say Exit. I want exit to be written in Red Color than Black one.
|
|
|
|
|
OnCtlColor[^] is one way of doing it.
Prasad
MS MVP - VC++
|
|
|
|
|
Are you sure this will work for button? I think owner draw is the only solution.
|
|
|
|
|
Naveen.R wrote: Are you sure this will work for button?
Not sure, . Yes, it wont work for button.
Naveen.R wrote: I think owner draw is the only solution.
Hamid's solution(below) is one way to do it.
Prasad
MS MVP - VC++
|
|
|
|
|
prasad_som wrote: Hamid's solution(below) is one way to do it.
AFAIK there is no WM_CTLCOLOR meesage now in windows messages. But it have been changed to
WM_CTLCOLORBTN
WM_CTLCOLOREDIT
WM_CTLCOLORDLG
WM_CTLCOLORLISTBOX
WM_CTLCOLORSCROLLBAR
WM_CTLCOLORSTATIC
The WM_CTLCOLOR in MFC, is made over the above messages. So handling the CWnd::OnCtlColor() and handling the WM_CTLCOLORBTN are same. So that too wont work for button.
|
|
|
|
|
Thanx,
I handle to WM_CTLCOLORBTN Message. But next, what to do. I dont know anything. I am beginner in VC++.
I tried out following things. but it dont work
case WM_CTLCOLORBTN:<br />
SetTextColor((HDC)wParam,RGB(255,0,0)); <br />
break;
And I want The Caption on Only One Button to be on different Color.
Please Help Me How to Do this
|
|
|
|
|
As I mentioned eariler this will not work. the only way to change the color of button is to owner draw it. There are many articles in the code project describing the "owner draw" in button. Check them.
|
|
|
|
|
|
Hi together,
I urgently need some constants from winspool.h (the SDK installed on this machine is too old).
Could someone have a look in winspool.h and give me the defines for
PRINTER_ATTRIBUTE_ALLOW_EMF
PRINTER_ATTRIBUTE_FRIENDLY_NAME
PRINTER_ATTRIBUTE_MACHINE
PRINTER_ATTRIBUTE_PUSHED_USER
PRINTER_ATTRIBUTE_PUSHED_MACHINE
(I need the values)
thanks in advance,
ralf.
|
|
|
|
|
winspool.h[^]
...but there there isn't that macro ...
are you sure that that values are define there?
Russell
|
|
|
|
|
Hi Russell,
_Russell_ wrote: winspool.h[^]
...but there isn't that macro ...
are you sure that these values are defined there?
I'm sure, but the problem is: they are new with Windows Vista and the SDK I have is too old.
So the wine sources also have to be updated (as soon someone finds the values).
In MSDN they are mentioned, but not the corresponding values:
http://msdn2.microsoft.com/en-us/library/ms535768.aspx[^]
btw:
The wine sources also don't have the following ones:
PRINTER_ATTRIBUTE_FAX 0x00004000
Windows XP: If set, printer is a fax printer. This can only be set by AddPrinter, but it can be retrieved by EnumPrinters and GetPrinter.
PRINTER_ATTRIBUTE_TS 0x00008000
Windows Server 2003: Indicates the printer is currently connected through a terminal server.
Thanks for your efforts,
ralf.
|
|
|
|
|
|
o.k. I'll answer the question by myself
(it took me almost a day to download the SDK because of a very slow internet connection).
It seems the constants are only available in the Vista SDK
(W2003ServerR2 and earlier don't have them)
PRINTER_ATTRIBUTE_ALLOW_EMF // doesn't exist in winspool.h
PRINTER_ATTRIBUTE_FRIENDLY_NAME 0x00100000
PRINTER_ATTRIBUTE_MACHINE 0x00080000
PRINTER_ATTRIBUTE_PUSHED_USER 0x00020000
PRINTER_ATTRIBUTE_PUSHED_MACHINE 0x00040000
hope, this will help someone...
Does someone know where PRINTER_ATTRIBUTE_ALLOW_EMF is defined?
|
|
|
|
|
Hi,
i have one text file, about 600-700 characters long, I try to read it in one CStfing variable. My code is :
CString strTemp;
while( ar.ReadString(strTemp) )
m_strFileBuffer += strTemp + _T(" ");
ar is CArchive, i try to put all the data from the file in m_strFileBuffer.
Problem is that when algorithm pass few times throught ReadString it stop to add data to m_strFileBuffer, it is very strange becouse the data from the file is readed properly in strTemp, then go to next line and try to execute 'm_strFileBuffer += strTemp + _T(" ");' but nothing hapend, algorithm go through this line, back to whili(), read next line from the file and try again to add data to m_strFileBUffer, and that is until ar go to end of the file. At the end i have only half of the file saved in the m_strFileBuffer.
Anyone can help with that : )
Thanks.
|
|
|
|
|
Was the file written using CArchive::WriteString()? If not, then you probably
shouldn't try to read it with a CArchive::ReadString().
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks a lot : )
it works fine now.
|
|
|
|
|
One possible reason that springs to mind is that the file somehow contains an embedded null. If this is true, strTemp probably *is* being added, but the embedded null stops the variable watch window from displaying the entire string. Also, if you try and use string manipulation routines on m_strFileBuffer, they will be affected by this null equally, and terminate the string early.
To test if this is the problem, try modifying your code to this:
CString strTemp;
const int MAX_LINE_LENGTH_EXPECTED = 1024 ;
TCHAR cBuffer[MAX_LINE_LENGTH_EXPECTED + 1];
while( ar.ReadString(cBuffer, MAX_LINE_LENGTH_EXPECTED) != NULL)
{
if (cBuffer[_tcslen(cBuffer) - 1] != _T('\r')
&& cBuffer[_tcslen(cBuffer) - 1] != _T('\n') )
{
// We may have a prematurely-truncated string.
// Or it will be the end of the file {:v)
assert(false); <=== put breakpoint on this line.
}
m_strFileBuffer += strTemp + _T(" ");
}
If there's an embedded null, the character found at where it believes the end of the string is will *not* be the <cr> / <lf> it should be. Obviously the genuine end of the file may also not end with CR / LF, so be prepared for that.
If you think your file might contain lines longer than 1024, adjust MAX_LINE_LENGTH_EXPECTED as appropriate.
|
|
|
|
|
Hey Freinds
I have a webbrowser control which displays a page , which has hyperlinks.
Is there any way by which if user clicks on any of the hyperlink(s) and the page should be opened another webbrowser control?
Regards
|
|
|
|
|
This[^] article demonstrates how to 'catch' navigations from the WebBrowser control. You can handle the OnBeforeNavigate2 event, which lets you redirect navigations elsewher.
Software Zen: delete this;
|
|
|
|
|
I have a hashing function for strings as follows:
<br />
template <int HASHSIZE>
class string_hash_nocase<br />
{<br />
public:<br />
int operator()(const char* s)<br />
{<br />
int hash = 1048577;<br />
char c;<br />
<br />
while (*s)<br />
{<br />
c = (*s >= 0x61 && *s <= 0x7a) ? (*s & 0xdf) : *s;<br />
hash = ((hash << 5) + hash) ^ c;<br />
++s;<br />
}<br />
<br />
return hash & (HASHSIZE - 1);<br />
}<br />
};<br />
May you have any idea on how to modify/extend it for Unicode (const wchar_t* )?
|
|
|
|
|
It looks similar to the djb2 hash.
I don't know why the lower case filter is there (*s >= 0x61 && *s < 0x7a) as it just filters out bit5 - never seen that done on a string hash before.
The lower-case filter isn't going to work in unicode as you don't know that the language will be english, however; if you really want to keep it try this:
int operator()(const wchar_t* s)
{
int h = 1048577;
wchar_t f = 0xdfdf,
c = 0;
while( *s ) {
c = iswlower(*s) ? (*s & f) : *s;
h = ((h << 5) + h) ^ c;
++s;
}
return h & (HASHSIZE - 1);
}
Not knowing how the 0xdf was chosen in the original i don't know if you should use 0xdfdf or 0x00df for f ... or something else entirely.
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|