|
|
In my opinion, you should assure that all of the Windows handles and objects are properly closed and do not produce resource leaks.
For instance, if you create many events, you should close them with CloseHandle. Your threads should end, so that the total number of threads, even suspended, must not grow indefinitely. If you allocate ojects with new, you have to delete them with delete, and so on. I think you should investigate with Windows Task Manager, or other tool, the evolution of your program.
I hope this helps.
|
|
|
|
|
|
hi
Iam creating one gaming project .The project contains Two static controls. When I click on static controls popupmenu will appear.But requirement is that selected fields in popup menu should be in own color .so please kindky help in my project.
-- modified at 2:47 Wednesday 6th September, 2006
#sanroop#
|
|
|
|
|
|
Hi
Iam very thankful to your reply,here i face the problem with selected fields.
They have with windows default color(blue), is there any possibility to change the default color blue.if there is posibility please kindly help in my project.
#sanroop#
|
|
|
|
|
oh did you see http://www.codeproject.com/menu/SidebarMenu.asp(second link) its not blue its red and gray
|
|
|
|
|
hi all,
i am having one problem with threading
i created one dialog based application whose work is to read the data from serial port and display it.so i created one thred for this work.
means now i got two threads one is application thread and other is serial communication thread which is created in OnInitDialog.
now everything is working i mean the thread got created it read some bytes
from port and now it wants to show the data so need to send this data to main
thread. so i am doing this with ::SendMessage() but it is giving access violation. i don't know why this is happening and currently i am not sending the data also i.e. buffer so please help me
below is code (stepwise)
1)In Oninitdialog
THREADPARAM *ptp = new THREADPARAM;
if(ptp)
{
memset(ptp->array,0,30);
strcpy(ptp->array,"Harshal");
ptp->appHandle = this->m_hWnd;
hSerialThread = CreateThread( NULL,
0,
(LPTHREAD_START_ROUTINE) SerialCommunication,
(LPVOID) NULL,
0,
&dwSerialThreadID);
}
2)Thread function
UINT SerialCommunication(LPVOID pParam)
{
int write_req=0;
THREADPARAM *ptp = (THREADPARAM *)pParam;
while(1)
{
if(write_req == 2)// send write request and read it
{
DWORD length=0;
DWORD dwRead=0;
if (WriteFile(hCom,
SEND_CMD, // pointer to data to write to file
NOOFBYTE, // number of bytes to write
&length, // pointer to number of bytes written
NULL) == 0)
{// write failed
write_req = 0;
continue;
}
// writefile succeeded issue readfile
char buffer[MAX_MESSAGE];
memset(buffer,0,MAX_MESSAGE);
if (!ReadFile(hCom, buffer, MAX_MESSAGE, &dwRead, NULL))
{
write_req = 0;
continue;
}
if(dwRead > 0)
{
//MessageBox(NULL,buffer,"Data with packet",MB_OK);
::SendMessage(ptp->appHandle,MY_SHOW_DATA,0,0);// error is here
}
write_req = 0;
}
else // only read from port and increment counter
{
DWORD dwRead=0;
char buffer[MAX_MESSAGE];
memset(buffer,0,MAX_MESSAGE);
if (!ReadFile(hCom, buffer, MAX_MESSAGE, &dwRead, NULL))
{
write_req++;
continue;
}
if(dwRead > 0)
{// you are in thread you need to send message to
// main application
//char a;
HWND hwnd = (HWND)AfxGetApp()->m_pMainWindow;
::SendMessage(ptp->appHandle,MY_SHOW_DATA,0,0);
//MessageBox(NULL,buffer,"Data without packet",MB_OK);
}
write_req++;
}
}
return 0;
}
3) Sent message function
LRESULT CReadDataDlg::OnShowDataMessage(UINT wParam, LONG lParam)
{
return 0;
}
4)the handle i am storing in appHandle is right or wrong?
Thanks and regards
Harshal
|
|
|
|
|
In my opinion, instead of
hSerialThread = CreateThread( ..., (LPVOID)NULL, ...);
you should try this:
hSerialThread = CreateThread( ..., (LPVOID)ptp, ...);
I hope it helps.
|
|
|
|
|
harsha_1234 wrote:
Thanks and regards
Scope Problem! you are not passing your PTP variable to Thread!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
How to get the window size of a popup window(CHtmlView)?
|
|
|
|
|
Isn't GetWindowRect works!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hi Guys,
Please suggest any API for getting the drive names in local system.
Thanks in Advance
Velayudhan
|
|
|
|
|
I've never tried it but you might want to take a look at the EnumServicesStatus API using the SERVICE_DRIVER flag.
Steve
|
|
|
|
|
|
I thought he was referring to device drivers but upon are more careful read I think that he may of meant drives.
Steve
|
|
|
|
|
Stephen Hewitt wrote: I thought he was referring to device drivers but upon are more careful read I think that he may of meant drives.
Me too after reading that Guys Question.. but it seems he require drives name!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
You need to get drive names or driver names
|
|
|
|
|
hi all,
I happened to a problem, I dynamic load a dll in a .exe, and the dll is a MFC regular DLL, when I use LoadLibrary to dynamic load the dll ,run the constuctor of the application object, it display a assert error dialog
ASSERT(AfxGetThread() == NULL),this is the place of asserting.
Is there anyone has thoughts abuot it can tell me,and we can talk abuot it.
thanks a lot.
lijie
|
|
|
|
|
It is difficult to answer, you don't provide enough informations. What you could do, is start your debugger and then, when the program crashes, open the callstack to see from where in your code the problem is coming.
|
|
|
|
|
Did you happenped to the situation I described, It just is this situation,I search it in the internet, and find someone has happed to it, but no solution. I am confuse it,it assert in the constructor, I don't know how to deal with it.
|
|
|
|
|
lj_wml wrote: I happened to a problem, I dynamic load a dll in a .exe, and the dll is a MFC regular DLL, when I use LoadLibrary to dynamic load the dll ,run the constuctor of the application object, it display a assert error dialog
ASSERT(AfxGetThread() == NULL),this is the place of asserting.
Did you try AFX_MANAGE_STATE( AfxGetStaticModuleState()); . This line should be added before calling any MFC related functions.
|
|
|
|
|
Hi guys,
I want to study splitter window applications. Please reply me some links related to source code of splitter window applications.
Thanks in Advance
Velayudhan
|
|
|
|
|
|
|