|
Hi All,
What I Need?
------------
I want to change the ToolButton's image with respect to different conditions.
What I did?
-----------
I creatd mfc application with ToolBar. And i added UI Command handler to the target ToolBar Button. In that handler i called CToolBar::SetButtonInfo() to change the button image into new one which i drawn.
What Stoped me?
--------------
After this step i saw my target ToolButton image is blinking. And also when pass the mouse pointer over ToolBar buttons, All buttons stops ToolTip popup.
What could be the possible reason to this??
Thanks n regards,
Rajan
"What Happened to a man is less signigicant than what happened inside him"
|
|
|
|
|
rajan4008 wrote: And i added UI Command handler to the target ToolBar Button. In that handler i called CToolBar::SetButtonInfo() to change the button image into new one which i drawn.
LOL What are you trying to do buddy. Why do you do this in the UI command handler. Everytime the UI is updated the Image will be reset. Hence I think the blinking.
Note: UI handlers must always try to use CCmdUI object to deal with UI updation. AFAIK you never know when it will be called. So it's safe to use the CCmdUI object. And don't try to do anything else.
You can use SetButtonInfo in the OnCreate function for the frame.
rajan4008 wrote: After this step i saw my target ToolButton image is blinking
OT: Now I know how to blink a toolbar button...He he;P
Jesus Loves You and Me <marquee direction="up" height="50" scrolldelay="1" step="1" scrollamount="1" style="background-color:'#44ccff'">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
Hi Buddy,
I wanna change image of ToolButton based on some condition. More clearly, My App has TreeView item. When user selects Target Item from the TreeView Items then i, wanna change image of my ToolButton. I have drawn 2 images-One is set as default and another one is set based on TreeView Item contents.
As you told, I already added SetButtonInfo() in Frame's OnCreate().However, if user selects something from TreeView which changes ToolButton's colour and he deselects the item then i, need to show the item as default image. Hence, I did SetButtonInfo() again in OnUpdateButtonxxxx().
For Instance:
void CMainFrame::OnUpdateButtonxxxx()
{
// Check wheather TreeView Item is Selected
theApp.ToggleButton();
}
void CMyApp::ToggleButton()
{
if(UserSelctedTreeViewItem)
SetButtonInfo(TOOLBUTTON_IND, XXXX, PUSHBUTTON, GREEN);
else
SetButtonInfo(TOOLBUTTON_IND, XXXX, PUSHBUTTON, GRAY);
}
NOTE: ToolTip is blocked due to this code. That's my major problem.
Some of My Doubts are:
1.If SetButtonInfo() is called with same ID then does it stop ToolTip? if yes how?
2.I accept that due to calling SetButtonInfo() again and again in the OnUpdateButton() Handler i'm getting blinking image. But it is not happening when i change the resource ID and also i'm getting ToolTip.
3.To achieve dynamic image toggling where should we call SetButtonInfo()?
Thanks in Advance,
Rajan
|
|
|
|
|
There are notification messages for this purpose.
Suppose you wanna handle selection change event then do this. (Write this in the parent window)
ON_NOTIFY_REFLECT(TVN_SELCHANGED, OnNotifySelChange)
in .h file
afx_msg void OnNotifySelChange(NMHDR* pNm, LRESULT *pRes);
in .cpp file
void CYouparentClass::OnNotifySelChange(NMHDR* pNm , LRESULT *pRes)
{
LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
}
Jesus Loves You and Me <marquee direction="up" height="50" scrolldelay="1" step="1" scrollamount="1" style="background-color:'#44ccff'">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
I want to create a time delay about 1/20 milisecond.
|
|
|
|
|
You can use QueryPerformanceCounter().
|
|
|
|
|
hai do u know assmbly language.
if u know 8086 assm lan Easily you can create a time delay
|
|
|
|
|
You probably can't reliably without going to extrodinary means. This is because Windows is not a Real time operating system, and at any stage your process could be preempted. However, the closest you can get is by calling
::Sleep(20)
In reality this will sleep more than twenty milliseconds quite often, because it relinquishes your timeslice in the process scheduler, but it is the best you can do without doing something really hard.
Despite what my mis-spelling co-poster tells you, going to assembly language will not offer you any benefit over the above, because it is no less subject to pre-emption than anything else. He/she might argue that you do not relinquish your timeslice as above, however the same can be accomplished in C++ too.
For example:
class Timer
{
public:
Timer();
void wait(DWORD ms);
private:
static int cyclesPerMs; // Number of loop iterations per millisecond
};
int Timer::cyclesPerMs = -1;
Timer::Timer()
{
const CALIBRATION_TICKS = 100000;
if(cyclesPerMs == -1)
{
// Calibrate timer
clock_t start = clock();
for(int i=0; i
|
|
|
|
|
What do you need the delay for?
Don't try it, just do it!
|
|
|
|
|
Hi,
My query is MFC related to Dialog box.
I want to change the Text property label of parent dialog box from its child dialog file.
How to change Text lable of parent dialog box from its child dialog file?
Thanks in advance
-Ramesh.
|
|
|
|
|
Use GetParent() from the Child Dialog.
GetParent()->SetWindowText("New title");
Jesus Loves You and Me <marquee direction="up" height="50" scrolldelay="1" step="1" scrollamount="1" style="background-color:'#44ccff'">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
Thanks,
But how to specify the Parents perticular Text property ID to change its lable from its child dialog file.
-Ramesh
|
|
|
|
|
Didn't get you. Be more clear. May be an illustration would do.
Jesus Loves You and Me <marquee direction="up" height="50" scrolldelay="1" step="1" scrollamount="1" style="background-color:'#44ccff'">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
I have a Text control on parent dialog box its ID is say IDC_TEXT1 & its Caption is "MY NAME". I want to change its caption from its another child dialog box file. When I click on child TAB page then parent IDC_TEXT1 caption should change to "NEW NAME".
Thanks
-Ramesh
|
|
|
|
|
((CYourDialogClass*)GetParent())->GetDlgItem(IDC_TEXT1)->SetWindowText("NEW NAME");
Jesus Loves You and Me <marquee direction="up" height="50" scrolldelay="1" step="1" scrollamount="1" style="background-color:'#44ccff'">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
Thanks
I have already tried that, but Child dialog box file not getting patent Text ID
Is it possible to use Notification message from child to parent to change the parent Text property caption.
If it is possible, Please let me know.
|
|
|
|
|
Is the child dialog a model dialog or modeless dialog ?
If its a modeless, did you pass the the parent window to the modeless dialog ?
-Prakash
|
|
|
|
|
It is Modal dialog box.
ya, I have passed the parent window to the modeless dialog
Thanks
-Ramesh
|
|
|
|
|
I want to read value of address 0000:0408 to check port LPT1. But there is error when I run this program.
How to read value of that address ?
|
|
|
|
|
Since noone else answers, I feel I have to.
The answer is very simple: You don't!
That's because all NT-versions of Windows (including i.e. Win2k, XP) doesn't allow processes (like programs) to access hardware directly.
In the old DOS-based Windows-versions (up to Me), it was all right.
There is a utlitity (available in several versions) called inpout32. Maybe you could use one of them? Search with Google for inpout32.
Kakan
|
|
|
|
|
kakan wrote: There is a utlitity (available in several versions) called inpout32. Maybe you could use one of them? Search with Google for inpout32.
I think they worked with win16 only and does not work with WinNT onwards.
-Prakash
|
|
|
|
|
|
even if you are able to access the memory address, probably you wont get what you are looking for.
What is that you want to do with LPT1, check CreateFile(...) windows api. You can create a handle to that port and do what you want to do with it.
-Prakash
|
|
|
|
|
Whats the major difference between CToolbar and CDialogBar ? .. Any fast help ???
|
|
|
|
|
Dialog bar can have controls that can otherwise only be placed on a Dialog box.
But toolbar can have buttons only. Ofcourse you can have combos and others too. But it's tedious.
Dialog bar is real cool.
Jesus Loves You and Me <marquee direction="up" height="50" scrolldelay="1" step="1" scrollamount="1" style="background-color:'#44ccff'">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|