|
Hi,
I am writing a callback TimerProc function inside my class with the prototype:
// Inside the CClassTimerDlg.h
public:
void CALLBACK EXPORT CClassTimerDlg::TimerProc
(
HWND hWnd, // handle of CWnd that called SetTimer
UINT nMsg, // WM_TIMER
UINT nIDEvent, // timer identification
DWORD dwTime // system time
);
// By the way, I copied this from the MSDN help
In my class implementation, I add a TimerProc as :
void CALLBACK EXPORT CClassTimerDlg::TimerProc
(
HWND hWnd, // handle of CWnd that called SetTimer
UINT nMsg, // WM_TIMER
UINT nIDEvent, // timer identification
DWORD dwTime // system time
)
{ Implementation of function TimerProc }
In one procedure handling a button inside the class, I put:
SetTimer(1,1000,TimerProc);
When I compile, I always receive the error message from the compiler for
the above line:
Error C2664: 'SetTimer' : cannot convert parameter 3
from 'void (struct HWND__ *,unsigned int,unsigned int,unsigned long)'
to 'void (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,unsigned long)'
None of the functions with this name in scope match the target type
How should I declare the TimerProc to correct this problem ?
Thanks a lot
|
|
|
|
|
|
a callback guy must be global or static class function
includeh10
|
|
|
|
|
Hi,
I am writing a callback TimerProc function inside my class with the prototype:
// Inside the CClassTimerDlg.h
public:
void CALLBACK EXPORT CClassTimerDlg::TimerProc
(
HWND hWnd, // handle of CWnd that called SetTimer
UINT nMsg, // WM_TIMER
UINT nIDEvent, // timer identification
DWORD dwTime // system time
);
// By the way, I copied this from the MSDN help
Below this text wrote some text by Microsoft:
The lpfnTimer callback function need not be named TimerProc, but it must be defined as follows:
void CALLBACK EXPORT TimerProc(
HWND hWnd, // handle of CWnd that called SetTimer
UINT nMsg, // WM_TIMER
UINT nIDEvent // timer identification
DWORD dwTime // system time
);
Well, I supose that is all, but ...
Branislav
|
|
|
|
|
Hello,
I have two icons that I wanna display based on the value of a check box. They're displayed in a static picture box. If the check box is checked, it displays one icon...you get the idea .
If I check the box after the app loads, it'll change the first time, but once the check box is clicked again, it won't load the other icon. I guess I need to overide a paint handler somewhere, but I'm not sure on how to do this.
Here's what I got:
HICON m_icon;<br />
<br />
if (m_enable = true)<br />
m_icon = ::LoadIcon (AfxGetInstanceHandle(), <br />
MAKEINTRESOURCE(IDI_ON));<br />
else if (m_enable = false)<br />
m_icon = ::LoadIcon (AfxGetInstanceHandle(), <br />
MAKEINTRESOURCE(IDI_OFF));<br />
<br />
((CStatic *)(GetDlgItem (IDC_PIC)))->SetIcon(m_icon);<br />
Pretty stupid on my part, --probably real straightforward.
Thanks in advance.
Matt
|
|
|
|
|
|
Thanks for your reply, Mike.
I tried your suggestion, but it still changes the first time, and just stays after that. I'm wondering if theres a problem with the logic?
Thanks.
|
|
|
|
|
ur using m_enable as a var bound to the checkbox i assume ... is it a control variable or a value variable? if its a value variable are u getting its changed state before your posted code?
either use UpdateData(TRUE); bad bad bad
or use a control variable and do mc_enable.GetCheck();
before testing value
if im way off base sorry
"... and so i said to him ... if it don't dance (or code) and you can't eat it either f**k it or throw it away" sonork: 100.18128 8028finder.com
|
|
|
|
|
Hi Matt,
Look what you write:
if (m_enable = true)
m_icon = ::LoadIcon (AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDI_ON));
else if (m_enable = false)
but you need write:
if (m_enable == true)
m_icon = ::LoadIcon (AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDI_ON));
else if (m_enable == false)
etc.
Branislav
|
|
|
|
|
doh!
didnt see the wood for the trees
"... and so i said to him ... if it don't dance (or code) and you can't eat it either f**k it or throw it away" sonork: 100.18128 8028finder.com
|
|
|
|
|
That was it! Thank you all for your help.
Matt
|
|
|
|
|
This forum is pretty good, i enjoy it very much.
i think there must other C++ forums like this, if i access more forums, i will learn more.
could you give me some info about other web address of C++ forums?
thx
includeh10
|
|
|
|
|
I think you'll be hard-prssed to find a forum for Visual C++ better than this one. I've seen a few and this is (IMHO) the best!!
Best Regards.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
You design a dialog box in the resource editor with the system font set to small fonts, for example. When the user changes the system font to large fonts all of the dialogs are screwed up. Static text controls are no longer big enough to hold the text and things overlap, etc.
I have thought of different ways to handle this.
1. Place and size the controls for the large fonts and live with extra space when small fonts are selected.
2. Design two sets of dialogs, one for small fonts and one for large fonts...seems like a lot of work.
3. Programmatically move and resize the controls based on the selected font. Similarly, dont't use the resource editor and create everything dynamically
I was just wondering how everyone else handles this problem. I typically use the first method, but I don't like the results...
Gary Kirkham
A working Program is one that has only unobserved bugs
|
|
|
|
|
On a similar note...Have you ever noticed that NT/2000 uses a different shade of gray than 95/98? It is only noticable if you have a graphic displayed on a dialog that has a gray background designed to blend with the dialog color.
Why are nt and 98 different? How do you handle this? Do you have two sets of graphics in the resources, one for NT and one for 98? Is there another way to handle this?
Gary Kirkham
A working Program is one that has only unobserved bugs
|
|
|
|
|
Actually, since users can change the dialog box color to whatever they want whenever they want, both on NT/2k *and* '98, it's a bad idea to depend on any particular color working unless you actually force the dialog to paint using that color. A technique i've used is to either use a masked bitmap (or icon) to avoid drawing the background, or to remap colors in the bitmap once loaded (use with caution; may change colors you don't wish to change).
Shog9
--
Maybe Java is kind of like God, it "works in mysterious ways". It seems like your apps are running slowly, because in the backgroud Java is solving world hunger, or finding the cure to cancer.
- Ryan Johnston, Don't die java!
|
|
|
|
|
the gray thing really bugs me!!!
if u have a 256 color image u can have the colors remapped on loading but ive not found a way (thats easy) for 16bit and higher bitmaps
*sigh*
"... and so i said to him ... if it don't dance (or code) and you can't eat it either f**k it or throw it away" sonork: 100.18128 8028finder.com
|
|
|
|
|
#1 is the way to go. #2 isn't a solution because there are more than just "small" and "large" fonts. You can set any font size up to 500% in the Display control panel. #3 is too much of a PITA, I only do it rarely when I have small, skinned dialogs and have to have the font a specific size. Otherwise, overriding the user's font selection is generally a rude thing to do.
--Mike--
Just released - RightClick-Encrypt v1.3 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
|
Please be nice to persons who post in the incorrect forums as they probably do not have a vast posting history such as yourself.
The correct way to behave is to give them a good flaming in the first instance, so they will learn immediatly to correct there ways.
Also you will gain a lot of satisfaction flaming somebody who you are never likely to meet in person.
Regardz
Colin J Davies
Sonork ID 100.9197:Colin
You are the intrepid one, always willing to leap into the fray! A serious character flaw, I might add, but entertaining.
Said byRoger Wright about me.
|
|
|
|
|
|
Thst not such a bad idea, don't wast eiopportunities to flame folk to a crisp and rememeber to turn the over and flame the other side, its embarrassing to have folk turn up any the roast is only halve done.
Regardz
Colin J Davies
Sonork ID 100.9197:Colin
You are the intrepid one, always willing to leap into the fray! A serious character flaw, I might add, but entertaining.
Said byRoger Wright about me.
|
|
|
|
|
I want to trap escape button like we do in Vb...
Eg.
when we write this under key press / keycode event in Vb..
if keyascii=27 then
unload me
exit sub
endif
|
|
|
|
|
I want to use the CListCtrl's LVS_REPORT ,but I have no idea in using the CListCtrl,anyone could give me a sample or the setps? I could not understand the MSDN 's .Thank .
YES, I am here.
|
|
|
|
|
Well, if you already have your list control on your dialog, those are the steps: (I suppose that m_wndList is the CListCtrl
m_wndList.ModifyStyle(0, LVS_REPORT);
<font color=green>
m_wndList.InsertColumn(0, "My name");
m_wndList.InsertColumn(1, "My phone");
<br>
<font color=green>
int nItem = m_wndList.InsertItem(m_wndList.GetItemsCount(), "Philip Patrick");
m_wndList.SetItem(nItem, 1, "111-111-222222");
That's all
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
|
|
|
|