|
prithaa wrote: ::SetBkColor(hDC, RGB(0xFF,0x00,0x00)); // text background color
return (LPARAM)(HBRUSH)hbr; // control background
}
Is hbr brush is properly initialised and lifetime of the object is valid?
if you want the background of CStatic and Text Background same then set the text background to transparent mode
::SetBkMode(hDC, TRANSPARENT); // SetBkColor(hDC, ...
|
|
|
|
|
Does your ONCTLCOLORSTATIC() get called?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello,
Thanks for your replies.
The ONCTLCOLORSTATIC()was not called when I debugged.
How do I call it?
Regards,
Pritha
|
|
|
|
|
prithaa wrote: How do I call it?
You don't. It gets called by the framework.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
for eg if i give 3 it has to generate binary states in sorting order in terms of no of 1's
|
|
|
|
|
If I understand your question correctly, see here.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Nice link, thanks
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
I got the following inline assembly code.
__asm {
MOV ECX, 0E2h
RDMSR
AND AX, 0BFF7h
WRMSR
} I have to port this to x64 code which does not allow inline assembly. What intrinsic functions should I use? Thanks!
Maxwell Chen
|
|
|
|
|
|
Rajkumar R wrote: rdmsr instruction[^] wrmsr instruction[^]
Do you mean that I won't need to worry about the MOV ECX and AND AX instructions? And __rdmsr and __wrmsr do that for me?
What about the size in x64?
In my original code (x86), does it only write back 16 bits (AX )? Or the whole EAX (32 bits)?
With __wrmsr , it writes 64 bits at a time?! Should I take care of anything in addition?
Maxwell Chen
|
|
|
|
|
"For more information, see the AMD documentation" from msdn
I was quickly seeing some documents I cannot find the MSR index equals E2h.
AFAIU, Three registers affects ECX, EAX, EDX.
The contents of ECX selects the MSR to be addressed by the
RDMSR and WRMSR instruction. The EDX and EAX registers contain the MSR values to be read or written; EDX—Upper 32 bits of MSR, EAX—Lower 32 bits of MSR. All MSRs are 64 bits wide. reference[^]
It seems valid fields in EAX for each MSR differs and you need to refer specifications, may be in your orginal code 16bit AX is masked and written back depends on the MSR on index E2h, I think intrinsic functions reads/writes the complete 64bit you need to take care it. I cannot comment more as i don't use .
|
|
|
|
|
Thanks for your great explanations! And please also refer to my reply to Mike (LINK[^]).
Maxwell Chen
|
|
|
|
|
Your original code always reads the whole 64-bit MSR into EDX:EAX and writes EDX:EAX into the 64-bit MSR. There are no partial reads and writes.
I don't know what you were trying to achieve with the original code, though, as there is no 0E2h model-specific register on Intel processors.
A literal translation would be
__int64 val = __rdmsr(0xe2);
val &= 0xBFF7;
__writemsr(0xe2, val); That will work on both x86 and x64 processors.
DoEvents: Generating unexpected recursion since 1991
|
|
|
|
|
Mike Dimmick wrote: I don't know what you were trying to achieve with the original code, though, as there is no 0E2h model-specific register on Intel processors.
The code in my OP (yes just four lines) came from the system ODM. I am doing the driver installer of card reader for certain upcoming new model of Gateway laptop. Due to some hardware reason, I have to disable the CLKRUN of Intel Device ID 2919 chip. So I made a helper utility to be invoked by the installer during driver installation. But before trying to disable CLKRUN, it has to disable the "Deep C4" of that Intel CPU (I did not ask), otherwise Windows (XP and Vista, 32- and 64-bit) freezes right away!
The code is to disable "Deep C4". It is working well under Vista 32-bit. I was going to make the 64-bit version today.
Thanks to your great help! I will try it next week.
Maxwell Chen
|
|
|
|
|
Mike Dimmick wrote: __int64 val = __rdmsr(0xe2);
val &= 0xBFF7;
__writemsr(0xe2, val);
I think, a minor adjustment is required for Mike's code in order to protect high order 48 bits.
<br />
__int64 val = __rdmsr(0xe2);<br />
val &= 0xffffffffffffbff7;<br />
__writemsr(0xe2, val);
High order bits should remain unchanged as in the original code below.
__asm {<br />
MOV ECX, 0E2h<br />
RDMSR<br />
AND AX, 0BFF7h<br />
WRMSR<br />
}
|
|
|
|
|
Maxwell Chen wrote: x64 code which does not allow inline assembly
It seems silly that they took it away as an option.
Is that just Microsoft taking inline assembly away or is that for most 64-bit compiler manufacturers?
|
|
|
|
|
Inline assembly is a real pain for the C++ parser. Consistently across all non-x86 compilers, they've been stripping it out. If you need to use assembly, use an assembler to assemble a whole function and call that.
DoEvents: Generating unexpected recursion since 1991
|
|
|
|
|
how to set opacity of image between 0-255 by using gdiplus.
Trioum
|
|
|
|
|
|
create a colormatrix object and set the appropriate values.
then set this matrix to the imageattributes object and then pass this object to drawimage().
Prasann
who else
|
|
|
|
|
Or you can use of CImage::AlphaBlend.
|
|
|
|
|
here is the problem, when i execute the app, the function connect doesnt return an error when the NIC is disabled. It just returnt 0, as if there is no error.
I am using C++
Does anyone have an idea why?
|
|
|
|
|
The question below is really an ugly question in a quiz. I run the code but don't know why, please explain clearly. Thanks in advanced.
#include <iostream>
using namespace std;
class A
{
public:
int adata;
A(int a) : adata(a)
{}
void fun1(){ cout<< "A::fun1" <<endl;}
virtual void fun2() {cout<< "A::fun2" <<endl;}
};
class B : public A
{
public:
int bdata;
B(int a, int b) : A(a), bdata(b)
{}
void fun1() { cout<< "B::fun1"<<endl;}
virtual void fun2() {cout<< "B::fun2" <<endl;}
void fun3() { bdata = 3; bdata++; cout << "bdata = "<<bdata <<endl;}
};
void printB1(B *pb)
{
pb->fun1();
}
void printB2(B &b)
{
b.fun2();
}
void printB3(B b)
{
b.fun2();
}
int main(void)
{
A a(0);
B *pb1 = (B *)&a;
pb1->fun1();
pb1->fun2();
pb1->fun3();
cout<< "=========================="<<endl;
A *pa = new A(3);
printB1((B *)pa);
printB2((B &)a);
delete pa;
return 0;
}
</iostream>
|
|
|
|
|
fantasy1215 wrote: //really don't know why could downcast like this?
Simple, because you can, this however doesn't mean you should.
This is a post fitting to be posted in the horror forum.
<code>A a(0);</code>
no problem creating an A object on the stack
<code>B *pb1 = (B *)&a;
Argh, creating a pointer to a B object on the stack and assign it the address of the A object
<code>pb1->fun1();</code>
this should work -> "B::fun1"
<code>pb1->fun2();
this should work also -> "B::fun2"
<code>pb1->fun3();
The hell has just opened up and corrupted the stack arround the A object
by the the execution of <code>bdata = 3; bdata++;</code>
return 0;
codito ergo sum
|
|
|
|
|
fantasy1215 wrote: I run the code but don't know why, please explain clearly
what's the why?
|
|
|
|