|
GetDCEx expects a HRGN which as you said is in the wParam and gives you back the DC.
HDC hdc;
hdc = GetDCEx(hwnd, (HRGN)wParam, DCX_WINDOW|DCX_INTERSECTRGN);
Also remember that returned DC is a screen DC so you have to BitBlt the bitmap onto it to display anything, simply selecting the bitmap onto it will do nothing other than attach a pointer. The fact you got the white box makes me think you didn't do it right so lets give you the basics, which go like this
SETUP (usually in WM_INITDIALOG):
HBITMAP hBmp;
HDC hMemDC;
hBmp = (HBITMAP) LoadImage(0, "SomeName.Bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hMemDC = CreateCompatibleDC(NULL);
if (hMemDC) SelectObject(hMemDC, hBmp);
BITMAP bm;
GetObject(hBmp, sizeof(bm), &bm);
BmpWth = bm.bmWidth;
BmpHt = bm.bmHeight;
USE (NC_PAINT):
HDC hdc = GetDCEx(hwnd, (HRGN)wParam, DCX_WINDOW|DCX_INTERSECTRGN);
BitBlt(hdc, ???, ???, BmpWth, BmpHt, hMemDC, 0, 0, SRCCOPY);
CLEANUP (usually WM_DESTROY):
DeleteObject(hBmp);
DeleteDC(hMemDC);
Finally if you want to add buttons etc there are a few more tricks and I will refer you to an article
Custom Titlebar | Catch22[^]
In vino veritas
modified 11-Aug-16 9:06am.
|
|
|
|
|
How about doing the same logic in an override of CStatic::DrawItem the ldrawitemstruct has a DC
I'll create a control with SS_OWNERDRAW DDX_Static or Control it
The frame work should then call my Drawitem ?
|
|
|
|
|
CStatic::Setbitmap didn't seem to do the trick and NCCLIENT encompasses the entire non client area of the dialog I am thinking of going with a owner draw SS_OWNERDRAW style
I think all I need to do is override CStatic::DrawItem
|
|
|
|
|
|
Looking for an idea solving following problem:
I have a "get()" function which returns the condition of an object stored in a member variable.
There is also some code that updates this _cond
int getCond() const { return _cond; }
void UpdateCond() { ... etc ... _cond=f(); ... }
In the whole code getCond() and UpdateCond() called are independetly, so that a "const" function could call "getCond()"
But there is one silly stupid use of the getCond() where the Update() is done in the getCond() code
So the former old coder maybe thought "update on request!"
int getCond() { UpdateCond(); return _cond; }
because UpdateCond() changes the member _cond getCond() cannot be const anymore.
Anyone an idea to overcome this problem?
(if not I have to change back this crunchy design into non-const getCond() functions...
There are about 100 in derived classes ...
|
|
|
|
|
FriendOfAsherah wrote: But there is one silly stupid use of the getCond() where the Update() is done in the getCond() code
There is only one clean solution:
Remove the wrong implementation and replace calls of it by two calls to UpdateCond() and getCond() .
You may also change UpdateCond() to return the state instead of returning nothing. This will not affect existing code calling UpdateCond() but allows you to use it instead of the non-const getCond() function.
|
|
|
|
|
seperating is really a work for months because this is somewhere in a 10x hierarchie and 100x parallel used chaotic class inheritance...
A { getCond() astract }; <- B <- C <-D ... about 10 Steps
A <-B1 ...
A <- B2 ...
and one of these C´s contains the thing with condUpdate()
I inherited this code ... hating it ..
maybe mutual or const_cast can help? but still update() is a non const function
I found another solution now which can work with the "non const" version which is used in the code...
But cleaning up this will be needed somedays..
|
|
|
|
|
I understand that it is a lot of work. But doing it the wrong way will make it even more complicated for future updates (especially when those have to be done by others).
The trick here is finding the code that calls this single non-const function (and expects that an update is performed) and replace that. You may use your development tools to find these calls (many have options like "Find Usages").
|
|
|
|
|
Hi
as a newbee to MFC C++ I have just been learning the hard way the number of corrections the visual studio debugger fixes for my mistakes
In addition when there is an exception in my code many times the exception address points to some windows DLL making it a challenge to track it to the User Code
Thanks for all those that have brought me to this point
|
|
|
|
|
|
Thanks so much I had the uninilized local variable problem. Thing Is dubugging release is hard because I cannt display variables even if I point to where the .pdb file is. I typically go into disassembly mode and get an idea of the value
Thanks
|
|
|
|
|
Please can anyone help me with the paddle game in c.Please
|
|
|
|
|
What specifically is your C question? Show the code you've put in place, explain what it does (not) do, and what you want it to do, and we'll help you with it.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Can you elaborate on what you have done with your game? Or what is it exactly you need help with?
"I've seen more information on a frickin' sticky note!" - Dave Kreskowiak
|
|
|
|
|
can i post the entire project so u can look through and debug the error for me + the question itself
|
|
|
|
|
I'm moving an older EVC++ project to VS2008 (OS change). I have it all compiling, but I can no longer edit my dialogs in the resource editor. When I attempt to open the editor, I receive an error dialog:
"C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\prsht.h(0)"
"error RC2247: SYMBOL name too long
There are a couple of solutions posted in SO, but so far, I'm still busted. I know the sdk is old, I've tried it on a VM with Windows 7 SDK, and it still does this.
Maybe one of you has encountered this error?
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
I would suggest the best way forward is to open the .RC file in the text editor (either in VS or using Notepad) and see if you can tidy up anything that looks out of place. And without seeing the resource statements it's impossible to guess what that may be.
|
|
|
|
|
Richard - are you suggesting I tidy up Microsoft's area? My resource file hasn't changed.
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
No I am just suggesting that other things have changed and an old resource file may not be compatible with the new versions of the resource compiler. But if you think it is Microsoft's problem you can always try one of their support forums.
|
|
|
|
|
RC and RES files have always been dangerous to rely on. Generally hold your bitmaps as bitmaps, and your dialog, menus and text as standard text files. Then script them or manually drag and drop them when you go onto a new version of Visual Studio.
You are basically asking Microsoft to make everything backwards compatible just so you can just pick up a prior project and compile it on the later version. The toolchain is long and subject to change and that is NEVER GOING TO HAPPEN. You always have the option to stay with and compile your code on VS2008.
A resource file is an ancillary file, do you expect your old manifest files to be backward compatible on the new compiler as well?
I am with Richard if you think Microsoft should support stuff to this level try the forums. I however feel you are being totally unreasonable its a few minutes work to deal with and you are almost certainly going to get a longer list of code changes that you will be required to vet with the new version. Out of interest how many code warnings and deprecated calls did you get when you loaded the old code.
In vino veritas
|
|
|
|
|
Well "Quote: RC and RES files have always been dangerous to rely on.
I understand your comments, but your first statement rather surprises me. Over the past 13 years or so, I've moved through EVC++, VS6, 2008, 2010, 2013, and now 2015. Never has it occurred to me that I should worry about the RC file. FWIW, others have had this problem prior to me.
Regarding backwards compatibility, not sure why you think I even suggested such a beast. But, if I use the "import source from an existing project", I sort of expect something semi functional. I don't think that is unreasonable.
I know it's fixable, as soon as I find the solution, I'll close out my own question.
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
I am surprised you never ran into the problem with RC files when you went from 16 bit to 32 bit programs because the header includes the language id and the Resource compiler used to always spit it about language not being set.
The solution is dead simple and was given to you by Richard ... open the RC file with a text editor its a straight text file.
Just pick the body up onto the clipboard and post it into a new empty resource file associated to the project. That is why we can't work out why you are stressed over it as it's like 1 min work with a text editor.
All the Resource compiler is complaining about it the header information in the old RC file which has includes directories that are wrong or header commands that aren't supported. The reason for that is most likely you used a resource kit wizzard and it's directing to that old directory or deprecated. You might have one or two resources you are using from the kit which will be trivial junk like ID's or perhaps an icon and if you have any just make your own replacements getting rid of dependency on the old kit.
I guess I should ask do you know what the RC body should look like and where the header ends? Even if you aren't familiar the format detail is so obvious I am sure if you spent 10 min looking at the file you will work it out. If you get stuck just paste the top 10-20 lines of the file and we can help.
In vino veritas
modified 8-Aug-16 13:33pm.
|
|
|
|
|
With insufficient information, I missed what Richard was saying. I have to laugh though. When Windows was 16 bit, I was off in Unix land. So, I've not made this transition. I did just get done with migrating the project as a whole, so the suggestion certainly makes sense.
Quote: Just pick the body up onto the clipboard and post it into a new empty resource file associated to the project. That is why we can't work out why you are stressed over it as it's like 1 min work with a text editor .
now I understand, sorry for being so dense. I'll get to this in the afternoon and see where it leads me.
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
modified 9-Aug-16 16:38pm.
|
|
|
|
|
Well, to update this query by me so that someone might be helped in the future:
VS2008 does not even come close to properly converting a project from eVC++. There are so many macros left undefined from the conversion that VS2008 is not able to handle its own includes let alone the application. The problem has absolutely ZERO to do with any specific resource file. It's caused by the pathetic migration effort made by VS2008.
Save yourself some time and (a) create a simple smart device project appropriate for you in VS2008. Then (b) migrate the existing code base in one at a time. Even then your dialog resource processing may need manual intervention.
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
modified 8-May-17 17:18pm.
|
|
|
|
|
I have a straight class hierarchy.
The base class only has a method F() which calls another method P().
This method P() has to be implemented in all of the child classes and is called by polymorphism.
How can I get sure (at compile time) that all child classes implement this method P()?
class CBase
{
private:
virtual void P() { printf("CBase::P\n"); }
public:
void F() { printf("Base: F()->P(): "), P(); }
};
class C1 : public CBase
{
private:
virtual void P() override { printf("C1::P\n"); }
};
class C2 : public C1
{
private:
virtual void P() override { printf("C2::P\n"); }
};
void main()
{
CBase* p = new CBase();
p->F();
p = new C1();
p->F();
p = new C2();
p->F();
}
The above is the structure, when all is correct and will result in:
Base: F()->P(): CBase::P
Base: F()->P(): C1::P
Base: F()->P(): C2::P
Now I made a mistake and forgot to implement P() in class C1
class C1 : public CBase
{
private:
};
the compiler doesn´t error and it will result in
Base: F()->P(): CBase::P
Base: F()->P(): CBase::P
Base: F()->P(): C2::P
The only Idea is to use an Interface declaring P() abstract.
But since C2 is derived from C1 from CBase how to do?
Followeing code will show up an error on missing P(), but also shows up warnings when all is correct:
warning C4584: 'C1': base class 'PI' is already base of 'CBase'
warning C4584: 'C2': base class 'PI' is already base of 'C1'
struct PI
{
virtual void P() abstract;
};
class CBase : public PI
{
private:
virtual void P() { printf("CBase::P\n"); }
public:
void F() { printf("Base: F()->P(): "), P(); }
};
class C1 : public CBase, public PI
{
private:
virtual void P() override { printf("C1::P\n"); }
};
class C2 : public C1, public PI
{
private:
virtual void P() override { printf("C2::P\n"); }
};
also it doesnt help at all because now I have to be sure to derive C1,C2, ... from PI too, not only from its parent
So what I need is "method P() has to be declared in all child classes!- error if it is not"
|
|
|
|