|
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
|
|
|
|
|
in my C++ app, i need to calculate curve length numerically.
let me say:
y=F(x);
d=x1-x0 is very small
curve length from x0 to x1 may be calculated as:
s=sqrt((y1-y0)*(y1-y0)+d*d);
where y1=F(x1), y0=F(x0);
s is straight line length from (x0,y0) to (x1,y1) actually.
result is not accurate.
i can not find aticles to get better result for general curve length in google, do u know any?
thx.
|
|
|
|
|
It is better to go through the book on numerical analysis.
You will find many methods there.
|
|
|
|
|
|
the program can do some numerical methods like taylor-mclauren. MOSS,newton-raphson method, secant method, bisection method,false position method and bairstow's method, curve fitting.
i'll be really grateful for any help for any of those methods.
thanks!!!
|
|
|
|
|
can somebody help me?..
-- modified at 4:48 Tuesday 4th September, 2007
|
|
|
|
|
hi, im sure this question is a regular one.
i'm making an app with bitmapbuttons and want to change bitmap on the button when hovering over them
can't seem to find any good articles about this subject.
heres a code i've been trying out, cant seem to get it to work.
//loaded the default button bitmaps in
OnInitDialog()
m_btn1.LoadBitmaps(IDB_MYBUTTON_DEFAULT);
//this works and sets the bitmaps on my buttons
//something like this is what i want to do
void CMyDlg::OnMouseMove(UINT nFlags, CPoint point)
{
CRect m_Rect;
m_btn1.GetWindowRect(m_Rect);
if (m_Rect.PtInRect(point))
{
//when mouse is over button change to this bitmap
m_btn1.LoadBitmaps(IDB_MYBUTTON_OVER);
}
}
any solutions?
tanx
|
|
|
|
|
You won't get a WM_MOUSEMOVE message in the dialog when the cursor is
moved over a button. You need to check for WM_MOUSEMOVE in the button class.
In your button class' OnMouseMove(), the first time it's called when the cursor
enters the button, you can use TrackMouseEvent() with the TME_LEAVE flag. Then
you'll get a WM_MOUSELEAVE message when the cursor is moved off the button
so you can set the bitmaps back to the original.
Also, after your LoadBitmaps() calls, you may need to call UpdateWindow() on the
button(s) to get them to redraw (maybe not, but if the button bitmaps aren't changing,
it's worth a try ).
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
tanx, i'll try that!
|
|
|
|
|
Given the coordinates on the desktop, how could I get a handle to the window at that position.
Sample code will be ok too. Thank you very much.
Tmay_99
|
|
|
|
|
POINT point={100,200};
HWND hWnd=::WindowFromPoint(point);
if (hWnd) {
// Do something
} else {
// Nothing here
}
|
|
|
|