|
I display the 32 bit icon with transparency using the AlphaBlend function. If the window with the icon is moved partially outside the monitor screen, the transparent area in some places is filled. Damaged places with partial transparency.. Any idea what it might be?
modified 9-Oct-19 13:23pm.
|
|
|
|
|
Member 12661464 wrote: Any idea what it might be? Maybe the Window is not getting refreshed properly. Do you have code that is controlling when the icon gets painted?
|
|
|
|
|
I just put the following code in the OnPaint () handler.
CPaintDC dc(this);
CDC *psrcDC = m_PictureControl.GetDC();
CDC dstDC;
dstDC.CreateCompatibleDC(psrcDC);
HBITMAP oldBmp = (HBITMAP)SelectObject(dstDC.m_hDC, startBitmap);
BLENDFUNCTION blend = { AC_SRC_OVER, 0,255, AC_SRC_ALPHA };
AlphaBlend(psrcDC->m_hDC, 0, 0, iWidth, iHeight, dstDC.m_hDC,0, 0, iWidth, iHeight, blend);
DeleteObject(oldBmp);
DeleteObject(startBitmap);
ReleaseDC(psrcDC);
|
|
|
|
|
Sorry, I cannot see anything obvious. Also, I am afraid I don't use MFC, so cannot try a similar test.
|
|
|
|
|
I want to create a macro that is fully executed at compile time (not runtime). If two values are both defined, then I want to check if they are equal. If at least one of them is not defined, then nothing should happen. I have come halfway, the following works great:
#define VALIDATE_ADDR(ADDR1,ADDR2) _Static_assert(ADDR1 == ADDR2, #ADDR1 " is not equal to " #ADDR2); However, when I try to nest that macro into another macro, then I run into trouble:
#define VALIDATE_ADDR_IF_THEY_BOTH_EXIST(ADDR1,ADDR2) \
#if defined(ADDR1) && defined(ADDR2) \
VALIDATE_ADDR(ADDR1, ADDR2) \
#endif Can someone please help me so I can do checks like this:
#define MY_ADDR_1 (1)
#define MY_ADDR_2 (2)
#define MY_ADDR_3 (3)
#ifdef MY_ADDR_4
#undef MY_ADDR_4
#endif
VALIDATE_ADDR_IF_THEY_BOTH_EXIST(MY_ADDR_1, MY_ADDR_2); VALIDATE_ADDR_IF_THEY_BOTH_EXIST(MY_ADDR_3, MY_ADDR_4);
|
|
|
|
|
AFAIK, that's not possible, since the # token is reserved for stringifying macro parameters within the macro expansion.
Also, I see that your definition for VALIDATE_ADDR ends in a semicolon. In general, you do not want to end a macro with a semicolon, since this can lead to, in the best case, a compiler error, and in the worst case, a subtle and hard to find bug.
|
|
|
|
|
Macros are purely compile time. If you want runtime checks then use functions. Macros such as the above tend to be more trouble than they are worth.
|
|
|
|
|
What do you mean? I've clearly stated I want compile time execution, not runtime execution of this macro. Are you thinking of the _Static_assert function? It is executed at compile time, I think it's a feature built into the gcc compiler.
|
|
|
|
|
Sorry I misread the question. I have tried a number of variants but cannot get it to work. it would appear that #define statements are not accepted inside a macro definition.
|
|
|
|
|
Btw, I don't need the VALIDATE_ADDR macro for anything, it's perfectly fine to replace it with the _Static_assert directly, if that makes anything easier.
|
|
|
|
|
I have some hard coded strings which I wanted to add to the String Table and load that string from the string table.
From the resource view, i go to the string table and gave ID,value and caption there.
and tries to load by doing this.
CString temp;
temp.LoadString(IDS_STRING1);
But its giving me IDS_STRING1 is undefined. What is the correct way to do this?
Thanks in advance.
|
|
|
|
|
I found what I did wrong. Thanks
|
|
|
|
|
what was wrong ? how did you fix it ?
I'd rather be phishing!
|
|
|
|
|
I gave the value which is already there.. I gave a different number which is not already used and that solve my problem.
|
|
|
|
|
How to implement singleton design pattern for database connection in MFC vc++?.
|
|
|
|
|
|
I have created like this. Am I going in the right direction?
Thanks in advance.
#include <afxdb.h>
#pragma once
class DatabaseSingleton : public CDatabase
{
static DatabaseSingleton* _instance;
DatabaseSingleton();
public:
static DatabaseSingleton* GetInstance();
virtual ~DatabaseSingleton();
private:
CString DSN;
CString UID;
CString PWD;
CString ConnectionString;
};
#include "stdafx.h"
#include "Medication_Administration.h"
#include "DatabaseSingleton.h"
DatabaseSingleton::DatabaseSingleton():DSN(_T("DemoDB")),UID(_T("root")),PWD(_T("root"))
{
ConnectionString.Format(_T("DSN=%s;UID=%s;PWD=%s"), DSN, UID, PWD);
OpenEx(ConnectionString);
}
DatabaseSingleton::~DatabaseSingleton()
{
Close();
}
DatabaseSingleton* DatabaseSingleton::GetInstance()
{
if (_instance == NULL)
{
_instance = new DatabaseSingleton();
}
return _instance;
}
|
|
|
|
|
Yes you do
|
|
|
|
|
Interested to know how you can answer this, not so simple, issue, but struggle with the ones below, which are basic C.
|
|
|
|
|
I have never learn C, just c++ ... and this code where I am working on is written for Linux, and for other compilers than VS. That is why I got tones of errors, one of them I don't know how to handle them without broke the functionality (I cannot try what I modify, so I am working blind).
modified 7-Oct-19 8:30am.
|
|
|
|
|
OT means "Off topic". I am replying to a message but discussing a different subject.
|
|
|
|
|
I have met an error that I cannot rid of:
error C2061: syntax error : identifier 'mode_t'
The fact is that this 'mode_t' is not declared in my sources, and I haven't founded on internet ... how can I get rid of this error ? Thank you for any hint, any suggestion !
|
|
|
|
|
|
Thank you Victor. Might be the late hour, I have seen that page, and I included
<sys/stat.h>
no change ...
|
|
|
|
|
I would guess that in some other platform it is used to refer to the following line of the stat type:
unsigned short st_mode;
Which you could verify by checking the original source.
So you could just add the following above your includes
typedef unsigned short mode_t;
|
|
|
|