|
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
|
|
|
|
|
|
|
This may sound Stupip, but, How do I set up this Browser Applet, so that i can return to a forum object I either posed or answered to. At the Moment I have tpo browse tru dozens of pages of new messages generated in my absence, to find back my thread. Surely there must be a better way. While on the subject, I get notified by Automatic email of responses. The URL's Provided do not appear to work.
LateNightsInNewry
|
|
|
|
|
You should post this to "Suggestions" forum.
Best,
Jun
|
|
|
|
|
If you are logged in, click on your user name (in the bar above the Help / Articles / Message Boards / etc menu bar.)
In the Who's Who page for yourself, click on the "Messages posted" link.
Select the post you want.
|
|
|
|
|
Hi all,
I seem to have lost my focus rect! When tabbing to a CButton you would normally expect to see a focus rect drawn on the button. In my app it doesn't. When mousing to it I get the typical XP highlight around it, but the actual dotted line that should also be drawn is missing.
Any ideas?
P.S. Same thing happens to Checkboxes. (I know they are related
Thanks!
|
|
|
|
|
anthonym7 wrote: P.S. Same thing happens to Checkboxes. (I know they are related
Just A Question Are they custom button?.. though it seems it not possible, but just trying!
"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
|
|
|
|
|
anthonym7 wrote: I seem to have lost my focus rect! When tabbing to a CButton you would normally expect to see a focus rect drawn on the button. In my app it doesn't. When mousing to it I get the typical XP highlight around it, but the actual dotted line that should also be drawn is missing.
Just a second, are you doing some kind of event handling in your button click. If so make sure that the focus is not getting shifted there.
For eg: If you are removing an item from list box on button click, then the focus goes there.
|
|
|
|
|