|
I have an Icon resource containing a 16x16 icon and a 32x32 icon.
When I use :
<br />
DrawIconEx(dc, 0, 0, icon, 16, 16, 0, 0, DI_NORMAL);<br />
I always get the 32x32 version of the icon scaled into a size of 16x16, instead of getting the 16x16 version.
When I supply the same Icon to a CTreeCtrl's CImageList, it manages to display the correct icon (16x16) on the tree.
How can I force DrawIconEx or any other method to pull out the small version of the icon ?
Thanks
|
|
|
|
|
DrawIconEx() simply renders the icon associated with the icon handle. How this handle was obtained is the real issue here. Did you use LoadIcon() , LoadImage() , or CreateIcon() ?
|
|
|
|
|
Thanks for the explanation
I was using a simple LoadIcon . I now switched to LoadImage with the 'desired size'.
Thanks again
|
|
|
|
|
hi
How to create a win32 static library and export a function?
with VC6 + sp4
thanks.
|
|
|
|
|
VC6 has a project type called 'Win32 Static Library'.
There is no need to export functions from a static library. Just provide a header file with a declaration.
Brad
|
|
|
|
|
I need to use a pointer to function in a generic class.
This is a peace of the code I've written:
// pointer to function declaration
void (*m_pNotifyDataAvailablity)();
// pointer to function assignment
void CMyClass::SetCallback(void(*p_pNotifyDataAvailablityCallback)(void))<br />
{<br />
m_pNotifyDataAvailablity = p_pNotifyDataAvailablityCallback;<br />
}
My problem is the following:
If I call the SetCallback method supplying a global function no problem occurs. When I try to supply a function member of CMyClass class the application doesn't compile and the following message is shown by the compiler:
error C2664: 'SetCallback' : cannot convert parameter 1 from 'void (void)' to 'void (__cdecl *)(void)'
None of the functions with this name in scope match the target type.
Can someone help me ??
Thanks a lot !!!
|
|
|
|
|
The reason this occurs is because the type of your function (the one which is a part of a class) isn't void(*func)(void).
Whenever you want to call a classe's function you need to call it in the context of an object of that class (i.e. supply a 'this' pointer), but when you'll try to call the function you received with SetCallback you won't have any 'this' (should the code would compile, which it doesn't
here's some code to help put you in the right direction:
(btw, this is also usable when you want a classe's function to run in it's own thread
<br />
class MyClass<br />
{<br />
public:<br />
void MyFunc(void);<br />
};<br />
<br />
<br />
void __cdecl worker(void *pVar)<br />
{<br />
((MyClass*)pVar)->MyFunc();<br />
}<br />
<br />
MyClass::MyClass()<br />
{<br />
worker(this);<br />
}<br />
<br />
<br />
What you need to do is seperate handling of global functions and class-contained functions.
I'm trying to understnad from your example what you were trying to do, perhaps you can define an abstract class 'IMyFunc', put a function 'MyFunc' there, then have all the classes you want to have this possible behaviour implement this class/interface and then you can call an external function, suplpy 'this' and have it call the function, or save the 'this' instead of the function pointer...
hmm, this came out abit confusing, perhaps you can elaborate mroe on waht you're trying to do
|
|
|
|
|
You need to change the callback function within the class to be static . You did not show all of the relevant code, so I can only guess as to what you might have.
void (*m_pNotifyDataAvailablity)();
class CMyClass
{
public:
CMyClass(){};
~CMyClass(){};
void SetCallback(void(*p_pNotifyDataAvailablityCallback)(void));
static void SomeCallback( void );
};
void CMyClass::SetCallback(void(*p_pNotifyDataAvailablityCallback)(void))
{
m_pNotifyDataAvailablity = p_pNotifyDataAvailablityCallback;
}
void CMyClass::SomeCallback( void )
{
AfxMessageBox("Howdy!");
}
...
CMyClass mc;
mc.SetCallback(CMyClass::SomeCallback); Otherwise, the compiler has no way of knowing that SomeCallback() is a member of CMyClass since it has no scope resolution operator.
|
|
|
|
|
If you call the SetCallback method supplying a function member of CMyClass class, you must declaring the function pointer as follows:
void (CMyClass::*m_pNotifyDataAvailablity)();
|
|
|
|
|
Hello all
I'm writing a console application in which I have to generate timer event at intervals 1 min,2 min,3 min,4 min and 5 minutes respectively. it's working fine upto 3 minutes interval but whenever I set 4 minutes or 5 minutes interval the timer event is generated immediately. Following is the code I'm using ...
LARGE_INTEGER liDueTime;
liDueTime.QuadPart=-600000000 * 3;// Generatiing timer event at 3 min interval
// Negative values indicate relative time
HANDLE hTimer=CreateWaitableTimer(NULL,TRUE,"WaitTimer");
SetWaitableTimer(hTimer, &liDueTime, 0, NULL, NULL, 0);
If I'm using -600000000 * 4 or 5 then the event is generated immediately. Can anyone help me in this?
Many thanks for your help.
Hari.
|
|
|
|
|
Since 600000000 * 4 is roughly 2^31 (maximum value of signed int ), it sounds like you are being plagued by OVERFLOW.
|
|
|
|
|
Hello David
Thanks for the reply. You're right the value is exceeding the range an integer can hold. But is there any way to solve my problem of setting time intervals.
If any one knows how to solve it, pls help.
Thanks
Hari.
|
|
|
|
|
Set the timer for one minute, and then each time the event is signaled (or the completion routine is called), increment a counter. When the counter is four, you know that four minutes have elapsed.
|
|
|
|
|
Hello David
Thanks for the reply, Using a counter solved the problem
Hari.
|
|
|
|
|
hi!
several days ago,I wrote my program with seh filter function using "_set_se_translator()",the debug version worked well as my expectation that it turned to my own exception filter specified in _set_se_translator() when the exception happened;but the release version did it as if there was no try_catch statement.why?
thanks!
|
|
|
|
|
You need to provide a bit more context about your code.
That said, I ran into something similar which may be the problem you're having. I had code similar to this:
int* pi = NULL;<br />
int i = *pi;
In debug builds, an exception was thrown from my SE handler and caught, but not in release builds. As it turned out, in release builds, the optimiser was correctly removing this code because it had no effect.
Not sure what you're doing, but if it's simple test case like mine, you might want to turn off the optimiser for that block of code:
#pragma optimize("", off)
Brad
|
|
|
|
|
I have a problem.there is a parent dialog, load two modeless dialog through the TAB control attached, only one modeless dialog show real-time,for don't move the modeless dialog in the tab controls,so the modeless dialog has only a Client,has no title bar.
When handle a button 's clicked command message in parent dialog, I want to trig a modeless dialog's button clicked event.So send message to the destination dialog e.g SendMessage(hModelessDialogWnd,WM_COMMAND,(WPARAM)IDC_BUTTONINMODELESS,0,0),but the destination show modeless dialog don't get the mesage and handle it.
1.How to get the handle of modeless dialog,beause the modelsess dialog has no title bar.
2.I attempt many method to get modeless dialog's pointer or handle.but debug it find don't get the modeless dialog's handle.
|
|
|
|
|
Hi,
is it necessary to initiate or reset LPTSTR zBuffer to zero after it was filled with a value?
Thanks, Mark
|
|
|
|
|
???
Don't try it, just do it!
|
|
|
|
|
zBuffer = 0; right??
Thanks, Mark
|
|
|
|
|
Yes, now you have given zBuffer the value 0.
If that makes any sense cant de deduced from what you have posted, as you failed to give any sort of helpful information.
So I think you know what you are doing.
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
I already created a SDI containg a dialog X with listbox, buttons..etc. Realise that i need a database as well, how do i start creating one and incorporate it into my SDI application? The interface dialog (for user to key in data) for this database will appear only when a specific button is pressed in dialog X. Urgent!
|
|
|
|
|
The easiest way is to create another SDI application with database support and note what gets added to the project. Add those items to your application. The biggest item will be a class derived from CRecordset .
|
|
|
|
|
Hey All,
Just wondering if anybody knows how to go about modifiying the http request header just before it's sent to the server. If I have an app with a CHttpView how would I go about viewing and modifying the header after somebody clicks on a link but before it's sent to the webserver.
I'm not exactly sure if OnBeforeNavigate2 is the one I should be using and I'm not sure how I go about modifying the Header (specifically the values that are "posted" to the server from a form (Is it CHttpArgList that I need to be dealing with?)).
Thanks in advance for any help lads.
Regards,
Brian Dela
IE 6 required: http://www.briandela.com[^] It works now.
|
|
|
|
|
1. Does anyone know if using templates causes classes to run slower in time versus there non-templated counter parts?
2. As I understand that templates allow for portability, is it wise to use them for time critical operations (eg. graphics processing, DSP, etc.)?
3. Are the STL classes fast?
Rich
"Programming today is a race between software engineers striving to build bigger and
better idiot-proff programs, and the Universe trying to produce bigger and better idiots. So far the Universe is winning." -- Rich Cook
|
|
|
|