|
I have a DLL function that gives an HBITMAP back to the calling application. I would like to store this off in a separate variable for use in WM_PAINT messages. What is the proper way to copy off this handle? I suppose I could copy into a memory DC, then extract it again, but that seems like too much work just to copy the bitmap data. Is there another way?
|
|
|
|
|
|
Hello,
I have a dialog with several controls on it. I want to make the controls non-editable based on some condition (the user would press a pushbutton to make them editable) is there any way that I can do this without setting the appropriate property for each control?
I know that I can do this by setting the appropriate property for each control on the dialog but I am looking for a way that I can do this in one ( or some ) function call in the dialog level so all controls become un-editable.
Best regards
|
|
|
|
|
you need to update each control individually.
unless you have millions of controls, it's not that big a problem.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Unfortunately, nothing like this is built in.
http://www.codeproject.com/buttonctrl/groupcheck123.asp
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I try to write programm with GDI+, put i noticed one problem - my screen is flicking even if i use the doublebuffer. What am i doing wrong??? When i used GDI and BitBlt function, everything was perfect.
I use GDI plus this way:
Graphics gr(dc.m_hdc);
Bitmap bm = new Bitmap(sizex,sizey);
Graphics gmem = Graphics::FromImage(bm);
gmem->DrawSomething();
gr.DrawImage(dc,0,0);
And another question - what about text drawn in any angle??? Is it necessery to uset rotatetransform function???
|
|
|
|
|
There is webpage which returns a string.
https://www.helloworld.com/getkey.html?a=someparam
after supplying appropriate parameter "a" it issues a plain text response and displays page with something like this answer=abc bdg
I want to write vc++ proggy which will request this string and then get the text response. Which functions do I use to request key and collect the text data from this link?
|
|
|
|
|
I have a modeless dialog that i use for chatting in my application, and have an 'Always on top' checkbox for it. This works, but if I minimize the main application, both dialogs disappear. How can I also make the dialog stay visible even if the main app is minimized?
[insert witty comment here]
bdiamond
|
|
|
|
|
Make the dialog a child of the desktop, not your main window.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
great answer, but how do I do that? (sorry if I sound like an idiot). I tried to use null as the argument for the CDialog superclass constructor, but that also doesn't work.
[insert witty comment here]
bdiamond
|
|
|
|
|
How about GetDesktopWindow() ?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I just tried that in my dialog's constructor, but I guess I'm doing something wrong.
CChatDlg::CChatDlg(CString str,int nUserID,CWnd* pParent ) <br />
: CDialog(CChatDlg::IDD, GetDesktopWindow())
[insert witty comment here]
bdiamond
|
|
|
|
|
It might be that you are being plagued by the fact that MFC does not have real modal dialogs. They are all modeless. It simulates a modal dialog by disabling the parent. See here and here.
Going back to your original problem, though, I'm curious why minimizing the main window causes either, let alone both, windows to disappear.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Let me rephrase that. I don't mean 'disappear', I just mean they both are no longer viewable when I minimize the main app. The main app is then iconic and visible in the taskbar, but the modeless dialog is also no longer visible. I have my app set up where if the user clicks the close button, the app is minimized to the system tray. The modeless dialog then stays up. But if I click minimize, then it doesn't
[insert witty comment here]
bdiamond
|
|
|
|
|
Hi guys !
I have developed one application which continuously runs on server. But because of some memory leaks in my code it hangs out after certain time period. Can any one can help it out plz. Or any other function that can show the current memory or Total Commit memory or Memory Usage. Plz. My code is also pasted here. If you can show me some change in my code it will be worth while.
------------------------------------------------------------------
int __stdcall CompressEncode (char* sIn, char* sKey, char** sOut, long* lOutlen)
{
int iResult = 0;
if (strlen(sIn) > 400)
{
iResult = CompressData(sIn, sKey, sOut, lOutlen);
}
else
{
iResult = 1;
AES_EncodeForService(sIn, sKey, sOut, lOutlen);
if (!strstr(*sOut, "<AES_ENCODE>"))
iResult = -4;
}
return iResult;
}
int CompressData (char* sIn, char* sKey, char** sOut, long* lOutlen)
{
Byte *compr, *uncompr;
uLong comprLen = 16384*sizeof(int); /* don't overflow on MSDOS */
uLong uncomprLen = comprLen;
static const char* myVersion = ZLIB_VERSION;
if (zlibVersion()[0] != myVersion[0])
return -1;
compr = (Byte*)calloc((uInt)comprLen, 1);
uncompr = (Byte*)calloc((uInt)uncomprLen, 1);
if (compr == Z_NULL || uncompr == Z_NULL)
return -2;
uncomprLen = strlen (sIn);
int iResult = test_compress(compr, &comprLen, (Bytef*)sIn, uncomprLen);
if (iResult != 0)
return -3;
byte *buffer, key[32];
unsigned int bufLen;
unsigned int err;
ailaes demo;
char s2[33] = "";
int len = strlen(sKey);
if (len > 64)
len = 64;
for (int i = 0, j = 0; i < len; i ++, j ++)
{
char sTemp[2] = "";
sTemp[0] = sKey[i];
sTemp[1] = 0;
int c = 0;
if (!stricmp(sTemp, "0") || !stricmp(sTemp, "1") || !stricmp(sTemp, "2") || !stricmp(sTemp, "3") || !stricmp(sTemp, "4") || !stricmp(sTemp, "5") || !stricmp(sTemp, "6") || !stricmp(sTemp, "7") || !stricmp(sTemp, "8") || !stricmp(sTemp, "9"))
c = atol(sTemp) * 16;
else if (!stricmp(sTemp, "A") || !stricmp(sTemp, "a"))
c = 10 * 16;
else if (!stricmp(sTemp, "B") || !stricmp(sTemp, "b"))
c = 11 * 16;
else if (!stricmp(sTemp, "C") || !stricmp(sTemp, "c"))
c = 12 * 16;
else if (!stricmp(sTemp, "D") || !stricmp(sTemp, "d"))
c = 13 * 16;
else if (!stricmp(sTemp, "E") || !stricmp(sTemp, "e"))
c = 14 * 16;
else if (!stricmp(sTemp, "F") || !stricmp(sTemp, "f"))
c = 15 * 16;
sTemp[0] = sKey[i + 1];
sTemp[1] = 0;
i ++;
if (!stricmp(sTemp, "0") || !stricmp(sTemp, "1") || !stricmp(sTemp, "2") || !stricmp(sTemp, "3") || !stricmp(sTemp, "4") || !stricmp(sTemp, "5") || !stricmp(sTemp, "6") || !stricmp(sTemp, "7") || !stricmp(sTemp, "8") || !stricmp(sTemp, "9"))
c += atol(sTemp);
else if (!stricmp(sTemp, "A") || !stricmp(sTemp, "a"))
c += 10;
else if (!stricmp(sTemp, "B") || !stricmp(sTemp, "b"))
c += 11;
else if (!stricmp(sTemp, "C") || !stricmp(sTemp, "c"))
c += 12;
else if (!stricmp(sTemp, "D") || !stricmp(sTemp, "d"))
c += 13;
else if (!stricmp(sTemp, "E") || !stricmp(sTemp, "e"))
c += 14;
else if (!stricmp(sTemp, "F") || !stricmp(sTemp, "f"))
c += 15;
s2[j] = c;
}
s2[j] = 0;
// pad out the input string to be an even block size
err = demo.strToBlock((char*)compr, comprLen, &buffer, &bufLen);
memmove(key, s2, 32);
demo.init(CBC, key);
// encript the buffer
err = demo.encrypt(buffer, bufLen);
if (err != 0)
return -4;
// encode the crypto buffer so it can pass as a null terminated string
*sOut = ESCencode( (char*)buffer, bufLen);
*lOutlen = strlen(*sOut);
free (buffer);
free (compr);
free (uncompr);
buffer = NULL;
compr = NULL;
uncompr = NULL;
return 1;
}
int test_compress(Byte *compr, uLong *comprLen, Byte *uncompr, uLong uncomprLen)
{
int err;
err = compress(compr, comprLen, (const Bytef*)uncompr, uncomprLen);
// CHECK_ERR(err, "compress");
return err;
}
int ZEXPORT compress (dest, destLen, source, sourceLen)
Bytef *dest;
uLongf *destLen;
const Bytef *source;
uLong sourceLen;
{
return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
}
int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
Bytef *dest;
uLongf *destLen;
const Bytef *source;
uLong sourceLen;
int level;
{
z_stream stream;
int err;
stream.next_in = (Bytef*)source;
stream.avail_in = (uInt)sourceLen;
#ifdef MAXSEG_64K
/* Check for source > 64K on 16-bit machine: */
if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
#endif
stream.next_out = dest;
stream.avail_out = (uInt)*destLen;
if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
stream.zalloc = (alloc_func)0;
stream.zfree = (free_func)0;
stream.opaque = (voidpf)0;
err = deflateInit(&stream, level);
if (err != Z_OK) return err;
err = deflate(&stream, Z_FINISH);
if (err != Z_STREAM_END) {
deflateEnd(&stream);
return err == Z_OK ? Z_BUF_ERROR : err;
}
*destLen = stream.total_out;
err = deflateEnd(&stream);
return err;
}
|
|
|
|
|
For every call to calloc() , regardless of the execution path, there needs to be a corresponding call to free() . You do not have that here. For example:
compr = (Byte*)calloc((uInt)comprLen, 1);
uncompr = (Byte*)calloc((uInt)uncomprLen, 1);
if (compr == Z_NULL || uncompr == Z_NULL)
return -2;
uncomprLen = strlen (sIn);
int iResult = test_compress(compr, &comprLen, (Bytef*)sIn, uncomprLen);
if (iResult != 0)
return -3;
Until you can get these type of problems addressed, the symptoms you describe are not surprising.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Why are you doing so many string compares on strings of one byte ? A simple character comparison would be quite a bit faster.
Also - stricmp is a case-insensitive string compare so there is no need to evaluate with both the upper and lower case versions of strings.
Your code could be optimized considerably.
__________________________________________
a two cent stamp short of going postal.
|
|
|
|
|
Friends,
I am doing some database work using Visual C++. For the first time i am using 'DataGrid Control'. Problem is that, i am unable to "edit" datagrid text if the query i execuated consists of "joins". Can anyone tell me that how can i overcome this problem. Can you tell me whether "Hierarichal Flex grid is the solution ??
|
|
|
|
|
Last time I checked, JOINs weren't editable.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Friend,
I am doing database work for first time in VC++. There is lots of hardwork involved as compared to Visual Basic. But i feel that i am not following right path. Are "data controls" i am using are good solution, or there is some better solution. Can i insert combo box in the cells of datagrid control or other such controls. If not then how can i make my life easy for doing database programming in Visual C++. Please suggest me the right way to follow ??
|
|
|
|
|
While many ways exist, some better than others, I tend to use ODBC and CDatabase /CRecordset objects. Give this section of CP a try.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I write custom ActiveX controls for an application that has been slow to support ActiveX completely. In fact, only the recent release of the software claims to support the ability to modify and save ActiveX control properties during design time. So, I plopped my custom controls on a form, but no properties.
The application developers informed me that the design tools only look for properties by scanning the "methods" section of a control's type library rather than the "properties" section. Of course, my properties are all listed on "properties" because VC++ 6.0 does this automatically when you add properties via the Class Wizard.
Example: here's what my property looks like:
dispinterface _DMyControl
{
properties:
[id(1)] BSTR Caption;
methods:
[id(DISPID_ABOUTBOX)] void AboutBox();
};
But, here's what the application would prefer:
dispinterface _DMyControl
{
properties:
methods:
[id(0x00000001), propget] BSTR Caption();
[id(0x00000001), propput] void Caption([in] BSTR lpszNewValue);
[id(DISPID_ABOUTBOX)] void AboutBox();
};
My question is: does anyone have information or an opinion on which method is preferrable? I ask because the application developers refuse to support straight "properties" on the grounds that so few controls use this paradigm. I want to know if there is a reason I should conform to using purely methods or if I should push the company to support properties.
Kevin Fournier
SRP Computer Solutions, Inc.
|
|
|
|
|
Pls somebudy give me that,pls don't give any refrence of MS gina stub or MSgina hook i want real gina code
thanks in advance
-----------------------------
"I Think It will Work"
Formerly Known As "Alok The Programmer" at CP
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
|
Yes,With all due Respect,
sir,
I am including the Smartcard functionality to the login dialog that why i need real source code of MSGINA,as i come to know MS is giving it for free.
thanks
-----------------------------
"I Think It will Work"
Formerly Known As "Alok The Programmer" at CP
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|