|
Could you please rephrase? I didn't get you...
|
|
|
|
|
i hav a application in system tray based i.e when click the minimise button icon will be moved to system tray .
i finished all (i.e minise to tray and popup menu )
now the problm is there r two button called start ,stop button
when i clicked start button , corresponding function is doing well and the button should be disabled (stop button - enabled)
when i clicked stop button corresponding function is doing well and this button should be disabled (start button - enabled )
u say how to disable.
i tried using getting id of the button but run time error ocurs (NO SYMBOLS ARE LOADED FOR ANY CALL STACK FRAME )
please help me
k.guru moorthy
|
|
|
|
|
If you are using MFC, then you can do it as follows
GetDlgItem(IDC_BUTTON1)->EnableWindow( FALSE );
OR
m_btnButton1.EnableWindow( FALSE );
But why it crashes? How did you disable it?
|
|
|
|
|
Cbutton* newbutt=((CButton *)getdlgitem(id_popupmenu_start);
newbutt->enablewindow(true);
k.guru moorthy
|
|
|
|
|
Where are you calling this? And did you verify that the pointer is valid?
|
|
|
|
|
Did you want to disable button?
|
|
|
|
|
My program would crash when it goes to CListCtl::InsertItem().The codes like bellow:
//get_wstring() will return a std::wstring object here,count is the rows I want to insert
for(int i=0;i<count;++i){>
std::wstring str = get_wstring();
CString temp(str);
//m_list is a CListCtl control
AfxMessageBox(temp);
m_list.InsertItem(i,temp);//crash here
}
the codes would crash when str string is not in my local language page(so the content of temp would be a strang string).But AfxMessageBox works well.
Someone would like to tell me why and how to fix such errors?
Thanks.
Merry Chrismas!
|
|
|
|
|
The cause might be the std::wstring, or the construction of CString from std::wstring. Please try this and see if it also crashes?!
m_list.InsertItem(i, "test");
Maxwell Chen
|
|
|
|
|
Of course not.
No matter what content of temp(CString object),AfxMessageBox() would show the real content of temp.But when its content like "ß??z???"(string like this were read from some file),InsertItem() would crash.
modified on Tuesday, December 25, 2007 11:57:34 PM
|
|
|
|
|
kcynic wrote: the codes would crash when str string is not in my local language page
Make your application UNICODE compatible and then try.( by defining _UNICODE in the project settings )
|
|
|
|
|
Yes,I compiled the project as UNICODE version,I forgot to say.
|
|
|
|
|
ok. check whether your strings are null terminated.
|
|
|
|
|
my strings are null terminated.If not,I think the CString constructor would crash too.
In addition,AfxMessageBox works well.
In fact,the codes work well for a PC,crashs for another!
|
|
|
|
|
Now,I found that,the problem is not InsertItem,but is CString or std::wstring.
//
std::wstring get_wstring(int tag)
{
wchar_t * s = NULL;
int len = function_ret_wstring(tag,&s);//return the characters in s,s is null terminated
std::wstring ss = s;
free(s);//s was alloced by function_ret_wstring() on heap
return ss;
}
//in the UI
void SomeClass::ShowItems()
{
for(int i=0;i<item_count;++i)>
{
CString temp(L"");
temp = get_wstring(tag1).c_str();
m_list.InsertItem(i,temp);
temp = get_wstring(tag2).c_str();
m_list.SetItemText(i,1,temp);
temp = get_wstring(tag3).c_str();
m_list.SetItemText(i,2,temp);
}
}
It is very strang,the codes work well on some computers,but would crash on some computers,too.
Because,the computer which run the codes crashedly have no VC installed,I could not debug.But I think the problem is the deconstructor of CString or std::wstring,Someone would like to give me some advise I will be very appreciate.
Thanks
|
|
|
|
|
Still i didnt get any idea...
<blockquote class="FQ"><div class="FQA">kcynic wrote:</div>free(s);//s was alloced by function_ret_wstring() on heap</blockquote>
How ever you are using free() to deallocate the memeory. was that memory allocated using the malloc()?
|
|
|
|
|
Yes,the memory was allocated using malloc()
|
|
|
|
|
What compiler and what CString (MFC, ATL, other?) are you using?
there should be no conversion from std::wstring to CString
(and there isn't in VC2005)
|
|
|
|
|
Yes,there is no conversion from std::wstring to CString.So,I used std::wstring's member function c_str() to get the buffer and translated it to CString object.
It's strange that,the codes would crash on some computers but not on some others!
I use VC2005
|
|
|
|
|
Hi all,
i've a problem when i'm trying to display an image object using the Graphics class under VC++.
The problem is what depending on the image file dpi , it renders in the screen in diferent a size bigger than the original. I think that the problem is in the dpi of the image.
But i don't know how to solve this problem. Anybody can help me plase?
|
|
|
|
|
How many pixels in the image, how many are displayed on the screen, if you don't stretch it.
DrawImage(Image* image, INT x, INT y)
DrawImage(Image* image, REAL x, REAL y)
...
If you want to display it in a specified rect, use:
DrawImage(Image* image, Rect& rect)
DrawImage(Image* image, RectF& rect)
...
Hope this helps a little.
|
|
|
|
|
Hello to all,
I am facing a problem while preparing an installable of my software.In an InstallShield an unknown file "Desktop_.ini" is getting created continuously and it has been spread every where and if i try to delete it then i can't delete it, it gives error that "Unable to remove selected file,please check for write access". Is anyone has faced this problem and know the solution please, can anybody tell me the solution to get rid of this file?
Thanks & Regards,
Anay
|
|
|
|
|
Looks like a virus. Try running latest antivirus.
Saadhinchaali
|
|
|
|
|
Hi there .
I can't call MD5Init() function. in fact i can't initialize MD5 message digest context .
here is my code :
#include <windows.h><br />
<br />
<br />
int __stdcall WinMain(HINSTANCE, HINSTANCE, LPSTR, int);<br />
int __stdcall WndProc(HWND, UINT, WPARAM, LPARAM);<br />
CCoding clsCoding;<br />
<br />
typedef struct {<br />
ULONG i[2];<br />
ULONG buf[4];<br />
unsigned char in[64];<br />
unsigned char digest[16];<br />
} MD5_CTX;<br />
<br />
typedef void (*MD5Init)(MD5_CTX*);<br />
<br />
typedef void (*MD5Update)(MD5_CTX*, unsigned char* input, unsigned int inlen);<br />
<br />
typedef void (*MD5Final)(MD5_CTX);<br />
<br />
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)<br />
{<br />
HINSTANCE hinstLib;<br />
<br />
MD5Init InitializeMD5;<br />
MD5Update UpdateMD5;<br />
MD5Final FinalizeMD5;<br />
<br />
MD5_CTX md5Ctx;<br />
<br />
<br />
<br />
hinstLib = LoadLibrary(L"Cryptdll.Dll");<br />
<br />
<br />
if (hinstLib != NULL)<br />
{<br />
InitializeMD5 = (MD5Init) GetProcAddress(hinstLib, ("MD5Init"));<br />
UpdateMD5 = (MD5Update) GetProcAddress(hinstLib, ("MD5Update"));<br />
FinalizeMD5 = (MD5Final) GetProcAddress(hinstLib, ("MD5Final"));<br />
<br />
if (InitializeMD5 != NULL)<br />
{ <br />
(InitializeMD5)(&md5Ctx);<br />
(UpdateMD5)(&md5Ctx,(unsigned char*) md5Ctx.in, 10);<br />
(FinalizeMD5)(md5Ctx);<br />
}<br />
}<br />
<br />
DialogBox(hInstance, MAKEINTRESOURCE(IDD_FORMMAIN), NULL, WndProc);<br />
return 0;<br />
}</windows.h>
Error :
Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
Where is the problem ?
DMASTER
|
|
|
|
|
You missed a WINAPI , change
Developer611 wrote: typedef void (*MD5Init)(MD5_CTX*);
to
typedef void (WINAPI *MD5Init)(MD5_CTX*);
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
Dear Pallini, Thanks to your reply.
DMASTER
|
|
|
|