|
Stan the man wrote: I want it like what multi language OS does in that I enter it in one application(keyboard) and it will "inject" the key message to another application's message buffer.
I don't really understand the part in which you are speaking about "multi language OS", can you be more explicit please ?
Otherwise, if you are working on windows, you can take a look at the PostMessage[^] function. But first you'll have to retrieve the HANDLE of the window (other guys here will be more helpfull than me on this point).
|
|
|
|
|
See if this article is of any help.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
Hey All,
Can anyone help me to make toggle button from CButton...
Poornima
|
|
|
|
|
In the handler function of your button, set the state to true if it must be pressed and to false if it must be released:
static bool bPressed = false;
if (bPressed)
{
bPressed = false;
m_MyButton->SetState(bPressed);
}
else
{
bPressed = true;
m_MyButton->SetState(bPressed);
}
|
|
|
|
|
<br />
static bool bPressed = false;<br />
bPressed = !bPressed;<br />
m_MyButton->SetState(bPressed);
The tigress is here
|
|
|
|
|
This one is even easier.
m_MyButton->SetState(!m_MyButton->GetState());
Maxwell Chen
|
|
|
|
|
Yes sure but then you still need to make an if/else statement if you want to do two differents things when the button is pressed or released
|
|
|
|
|
|
Take a static variable and keep on incrementing it by 1 on each click of the button. Check with the modulus operator. If the value returned is 0 do something, else do something else.
ex:
static int i;
void CMyClass::OnButton1()
{
i++;
if(i%2==0)
//Do something
else
//Do something else
}
Vision is Always important and so is your ATTITUDE.
Wishes.
Anshuman Dandekar
-- modified at 9:56 Friday 5th May, 2006
|
|
|
|
|
You won't have a toggle button in this way. This will just make two different things but the button will always be released (graphically I mean).
|
|
|
|
|
see radio buttons or checkboxes. they are actually CButtons, and they do have in their properties a flags called something like "push button" (see in the resource editor)...
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
It's probably the easiest solution
I used mine because I had to do the same but the buttons were on a toolbar (so you cannot control the properties with resource editor).
|
|
|
|
|
But i am creating a button with image.(customised one)... Say that i already have a CButton now i want to change that to toggle.
|
|
|
|
|
|
hmmm... Ok.... Can I make a radio button with Image and will it look like a normal button?
|
|
|
|
|
|
okay... How should i write Message Maps for two states(On/OFF)... I am creating everything at runtime
|
|
|
|
|
Message Maps ? I thought you were using the MFC's (CButton is part of the MFC), so you don't have to write message maps yourself. What are you trying to achieve exactly ?
|
|
|
|
|
Hey,
As i am creating everything at runtime i am writing the message maps.
And I got the solution also... I can just keep count of button pressed and writing my code accordingly ...
Thanks for the help
|
|
|
|
|
Ok, sorry, I misunderstood you (almost the week-end ).
Use it the same way as a normal button. But if you create them at runtime, you won't be able to configure them through the resource editor. So, the solution is to use the code I posted in my first thread.
So, you make the message map like for a standard button press and inside the function, you paste the code.
|
|
|
|
|
Is there anyother functions available... instead of static variable??
bcoz I may face problem for situation like,
just describing in steps.
1.I am pressing the button... It state will be set to true.
2. without releasing it say i am closing that window
3. Again i am opening the window and pressing it...
I will face unwanted behaviour. Is there anyother function call is there to get the state??
Hope I made it clear
|
|
|
|
|
atimpoo wrote: Hope I made it clear
Err, no, I didn't understand.
From which window are you speaking about ?? (You said 'that window')
|
|
|
|
|
ya.. I will explain it properly... say that i have an application running. A window is created by clicking a menu item. In that window i am having my toggle button.
Now i am clicking the toggle button first time. It state changes... Now i am closing the window.. and when i again open that window... That static variable wont be created again. It holds the previous value...
This is the problem i am facing it..
|
|
|
|
|
Change the scope of the static variable.
I mean outside the code of the window handler where you create the buttons
Knock out 'T' from CAN'T
You 'CAN' if you think you 'CAN'
|
|
|
|
|
Hi together,
I need some help to get the name of the local host from DNS (VC++6).
My problem is that the WINS entry is different from the DNS entry. So, gethostname() and gethostbyname/addr() always return the WINS entry and not the DNS entry. Moreover, I can't change the entries or configure the system
Can anybody help me on how to get the DNS entry (host name) anyway? For example, if I type "nslookup <IP of local host>" to the console, I get the wanted host name. I just need this functionality in C++.
Thank you very much for your help!
Marcus.
|
|
|
|