|
I have a Dialog that has many controls on it. It has multiple ComboBoxes that I have calling the same function when an item is selected in them. I am using CBN_SELCHANGE that calls my function. To get the ID of the control that was changed, I use:
CWnd *pwnd = GetFocus();
crtlid = pwnd->GetDlgCtrlID();
but the ID that is returned is always 1001 and is not the ID of any of the ComboBoxes - they start at 1454 in the resource.h file. None of the controls on the dialog has the ID 1001 so I am confused to what has the focus. Does anyone know what I am doing wrong. I am using VC++ 2005 for a Dialog based MFC application , and using MFC as a static library. Any help would be appreciated - Thanks in advance!
David
|
|
|
|
|
|
Thanks for the help - I will have a look and see if I can figure it out. I did find a way to make it work - In the properties I had the Type set as a Dropdown which I think lets you type in new entries in the EditBox - what has the focus must be that EditBox. If I change the Type to a DropList - fixed list, then when GetDlgCtrlID() runs, I get the ID that I am looking for. Thanks for the help again!
David
|
|
|
|
|
that's interesting... well, glad you have your code working
|
|
|
|
|
GetFocus returns a temporary CWnd, I don't know what the ID of that should be.
it might be that.
Watched code never compiles.
|
|
|
|
|
Thanks for the help. I did find a way to make it work - In the properties for the ComboBox, I had the Type set as a Dropdown which I think lets you type in new entries in the EditBox - what has the focus must be that EditBox. If I change the Type to a Drop List - fixed list, then when GetDlgCtrlID() runs, I get the ID that I am looking for. Thanks for the help again!
David
|
|
|
|
|
Even though the CWnd is temporary, the underlying HWND is not. So messages sent through the temporary object, still end up in the correct control, and thus, the ID should remain the same.
|
|
|
|
|
The information you need is passed back with the notification message as described here[^]. When investigating issues like this you should always go to the MSDN reference documentation first.
|
|
|
|
|
Hey guys. Lets say, i have such function, like:
void Stuff(int A, int *B);
So as you can see, B is OUT parameter. The question is, how would you call it from inline assembly code?
Something like this:
void Some(int A){
__asm
{
push 1
call dword ptr Some
}
int Some(int A, int B){
__asm
{
push 2
push 5
call dword ptr Some
}
but how to do it with this: void Stuff(int A, int *B) ? How to get B ?
Thanks
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
Ok, solved it myself.
#include <windows.h>
#include <iostream>
using namespace std;
void Func(int A, int *B, int *C)
{
*B += ++A;
*C *= *B + 1;
}
int main()
{
int B = 3;
int C = 6;
__asm
{
lea ecx, C
push ecx
xor ecx, ecx
lea ecx, B
push ecx
push 3
call dword ptr Func
add esp, 12
}
cout << B << " : " << C << endl;
}
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
How to extract two bits simultaneously from a byte ?
|
|
|
|
|
Use bitwise AND operator.
unsigned char b = 0xFF;
unsigned char result = (b & 0x03);
(0x03 has the lowest two bits set.)
|
|
|
|
|
Don't think it has to be unsigned, but this works great and is commonly used.
|
|
|
|
|
unsigned can make a big difference if the top bit is one of those involved.
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
not really, not if you're dealing with bit level operations... as long as you're not using the data to do arithmetic, but this type of logic is usually used for dealing with APIs and hardware type of operations.
|
|
|
|
|
As mentioned above, use '&' to test for a bit pattern. I've illustrated that in the inline function extract below.
If you don't have the actual values of the bits to test for though, you may need to combine the variables that contain the test bits. In that case use the bitwise or operator '|'. I've illustrated that in the inline function test2Flags below.
You can easily combine more than 2 flags to test for by combining several of them with '|'. See the last call to extract below.
typedef unsigned char byte;
const byte indicator1 = 0x01;
const byte indicator2 = 0x02;
const byte indicator3 = 0x04;
const byte indicator4 = 0x08;
const byte indicator5 = 0x10;
const byte indicator6 = 0x20;
const byte indicator7 = 0x40;
const byte indicator8 = 0x80;
inline byte extract(byte indicators, byte mask) {
return indicators & mask;
}
inline test2Flags(byte indicators, byte flag1, byte flag2) {
return extract(indicators, flag1 | flag2);
}
int main() {
byte myIndicator = 0x34;
byte testMyIndicators3and5 = test2Flags(myIndicator, indicator2, indicator5);
byte testSeveralFlags = extract(myIndicators, indicator2 | indicator3 | indicator4);
return 0;
}
Of course, you don't need to define any function for that, I just did this to enhance readability and focus on the relevant syntax.
|
|
|
|
|
Hi,
We are going to support our application for French localization (iso-8859-1 Windows-1252). The application developed using C++ and C# technologies. As per my understanding, if we support Unicode or MBCS (Multi-byte character set), we won’t get any data loss. Can we use normal string function for handle French characters or _MBCS requires for handle French characters?
Example:
Can we
if( *sz1 == 'A' ) for Character Comparison or
if( !_mbccmp( sz1, sz2) )
Thanks and Regards,
Selvam,
http://www15.brinkster.com/selvamselvam/
|
|
|
|
|
It looks like you plucked your question from here[^] where it explains the issue. It does not matter what character encoding you use if it's the same everywhere, just use the correct functions for your string manipulation, and ensure all constants are held in the correct encoding.
|
|
|
|
|
Hi Richard,
Thanks for your help. so, I can use ASCII functions(string manipulations, Windows API functions , etc) for my French application. Is it?
Thanks and Regards,
Selvam,
http://www15.brinkster.com/selvamselvam/
|
|
|
|
|
R.selvam wrote: so, I can use ASCII functions(string manipulations, Windows API functions , etc) for my French application. Is it?
Yes, assuming all your text is in ASCII.
|
|
|
|
|
Thank you.
Thanks and Regards,
Selvam,
http://www15.brinkster.com/selvamselvam/
|
|
|
|
|
On a tree control , with
m_Tree.ModifyStyle(TVS_CHECKBOXES,0);
m_Tree.ModifyStyle(0,TVS_CHECKBOXES);
I put checkbox style , but how can I turn off this style if they already exist ?
I try this , but it is a stupid :
m_Tree.ModifyStyle(~TVS_CHECKBOXES,0);
m_Tree.ModifyStyle(0,~TVS_CHECKBOXES);
modified on Tuesday, March 29, 2011 3:58 AM
|
|
|
|
|
Flaviu 2 wrote: m_Tree.ModifyStyle(TVS_CHECKBOXES,0);
Use GetStyle() [^] to check what styles are already set, and modify as appropriate.
|
|
|
|
|
And how to modify them if I want to set back to 0 ?
|
|
|
|
|
Check if that style bit is set in the return from GetStyle() and if so you can remove it; if not set then no action.
|
|
|
|