|
Neptune,
There is a sample MFC Extension DLL provided by Microsoft. Perhaps you should take a look at the source code and compare it to your project.
DLLHUSK MFC Extension DLL[^]
Best Wishes,
-David Delaune
|
|
|
|
|
Hi,
In visual studio 2005, I opened the dllhusk sample, it simply didn't work, I could neither open its properties nor run it!
Anyway, I've been so busy on other projects since then, thus I couldn't spend time on this one, though my mind was always busy with this problem.
Today while I was doing some tests on another project I found the reason for that assert:
In project properties:
"Configuration Properties->General->Character Set" should be set to "Use Multi-Byte Character Set" instead of "Use Unicode Character Set".
The interesting point is that visual studio sets this setting to "Use Unicode Character Set" by default causing these kind of issues to those who migrate their code from previous versions of visual studio without making any hint or warning.
Thank you again david for your feedbacks
|
|
|
|
|
Hello,
I developed an application for my client using VC++ 2005 (unmanaged) that monitors equipment at different remote sites. It communicates with the equipment through Leased Line or Dial-up modem. In my case, same modem is working as leased line and dial-up modem. The application is working fine when leased line is used, but with dial-up connection, sometimes it shows timeout. My client has a similar Win16 application which is working fine with same phone line, modem and equipment.
The equipment uses ACK/NAK for successful/unsuccessful data communication.
I am using a small speed of 2400 baud, opened for overlapped operation, "ReadIntervalTimeout" value is set to 1 and all the other timeout values are set to 0.
My port reader function is reading 1 byte at a time, and it is working fine for all other cases except for the dial-up modem. Is this the problem for timeout?
I have captured the data at timeout and analyzed the data byte by byte, found that port reader function is reading invalid data. Suppose, a valid data stream is 32 bytes in length, the reader function is reading all 32 bytes, failed to read last few byte(s) in time, but end up with a complete data stream of perfect length of 32.
Say, this is a valid data:
10 02 1c 00 43 4d 54 00 00 00 00 00 00 00 31 00
00 00 00 00 00 00 01 00 62 00 65 07 74 49 8a a1
But when timeout occurs, this data is getting read like this
10 02 1c 00 43 4d 54 00 00 00 00 00 00 00 31 00
00 00 00 00 00 00 00 01 00 62 00 65 07 74 49 8a
The last byte "a1" is read later but before that my function send the previous data for CRC check that will obviously failed. This thing is happening for large data stream.
Someone please tell me how I can handle this TIMEOUT problem.
Thanks in advance.
|
|
|
|
|
I've never used a modem, just a port for serial comms but have seen similar problems.
First I'd recommend if you are not using PortMon or a similar utility to do so to see exectly whats happening at a lower level.
Obviously you could extend the timeout but whilst 2mS might work, there's still (presumably) nothing in your code to handle what to do if it doesn't.
Why read a byte at a time? OK it works, but you could attempt to read the number of bytes expected in the whole expected message and then check the number of bytes read? You could then get, say 28 bytes when you expect 30, buffer them read again and add the first 2 bytes of the second read to the end of the buffer etc.
When using ports I work on the assumption that you may not get what you expect:
while(!bFullMessageReceived)
{
BOOL bRead = ::ReadFile(m_portHandle, static_cast<LPVOID>(ReadBuff), dwMaxBytesToRead,&dwBytesRead,NULL);
if(FALSE == bRead)
{
...
I would recommend treating a timeout as something that is a valid event, which it is. It's not an error: it happens and it not in your control, so you have to deal with it.
|
|
|
|
|
Thanks for your response.
As a matter of fact, I tried in all the ways I could think of to avoid that timeout. Now I realized why it did not work for me.
So, I think that my program is not sending NAK to the equipment properly. By the way, I am using "WriteFile" to send single character of NAK (21), is it correct to use this function to send a single character or should I use "TransmitCommChar"?
Thanks again.
|
|
|
|
|
Hi,
You are probably right about the NAK error, there will be some underlying cause for your time-out and this may be it.
I have seen this in code I recently looked at: No sending of ACK (or NAK). Also no dealing with an error-code which is being returned for some reason when the code expected an ACK.
Until you mentioned TransmitCommChar I didn't know about it (so thanks) but it does sound OK to use as it takes priority over any other characters in the output buffer. Conversly, the only one who will place characters in the output buffer is yourself - so if you know you haven't put any there WriteFile will work OK as well.
Jonathan
|
|
|
|
|
My friend "Create window in Work thread" when she need a message pump (message loop? I am not sure, sorry I am a beginner).
She just create a window, and then do a loop like WndProc does.
I am also worry about if it could work
I know that MFC has a UI thread that with a message Pump can do this without creating a window. But I cannot persuade she to use UI thread instead of a "Work thread with window", because of my pity knowledge .
could any one help me about that.
|
|
|
|
|
The only difference between a UI thread and a worker thread is that a UI thread has a message loop.
So what your friend has created is a UI thread rather than a worker thread.
«_Superman_»
|
|
|
|
|
|
Thanks for answer my qustion, «_Superman_» and Josh_Jackson
I trace to the source code of the CWinThread into thrdcore.cpp.
(1) CWinThread is derived from CCmdTarget, That bring to CWinThread the Message_Map so it can get message
from OS???
(2) If so Why CWinThread need a CWnd in UINT APIENTRY _AfxThreadEntry(void* pParam)
UINT APIENTRY _AfxThreadEntry(void* pParam)
{
.....
CWnd threadWnd;
TRY
{
.... if (pApp != NULL &&
pThread->m_pMainWnd == NULL && pApp->m_pMainWnd->GetSafeHwnd() != NULL)
{
threadWnd.Attach(pApp->m_pMainWnd->m_hWnd);
pThread->m_pMainWnd = &threadWnd;
}
|
|
|
|
|
Dear friends
Any body knows how can I create GUI application form in C++ code and create instalation program for it?
|
|
|
|
|
hdavari wrote: create GUI application form in C++ code
With MFC (or QT or WTL, or ...) or .net Framework
hdavari wrote: create instalation program for it?
With installer softwares (for example: inno setup, ... )
Do you have more precise questions ?
This signature was proudly tested on animals.
|
|
|
|
|
hdavari wrote: Any body knows how can I create GUI application form in C++ code and create instalation program for it?
Yes, a lot of us here do. What question(s) do you have about it?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
In ListBox i'm using it to display the Strings,
After adding it to resource it's property is set as ownerdraw fixed and Single selection
When i create an object of it, as CCheckListBox the items are being displayed,
but when i create an object of CListbox/CNewListBox(Which is derived from CListBox) the items are not visible.
I overriden the DrawItem in CNewListBox, i suspect there must be some problem with the overriden function.
But the irony is when i use the same class in a small application it is working perfect, but in my main application the listbox items are not at all visible.
void CNewListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
if (lpDrawItemStruct->itemID == (UINT)-1)
{
// Draws item text
int h = lpDrawItemStruct->rcItem.bottom - lpDrawItemStruct->rcItem.top;
pDC->SetBkMode(TRANSPARENT);
lpDrawItemStruct->rcItem.left += h;
int i= pDC->DrawText((LPCTSTR)lpDrawItemStruct->itemData, &lpDrawItemStruct->rcItem, DT_LEFT);
}
}
What's the wrong/ or missing?
Would Appreciate any help
modified on Sunday, January 25, 2009 11:40 PM
|
|
|
|
|
Do you specify LBS_HASSTRINGS (checkbox in resource editor)?
|
|
|
|
|
yes, LBS_OWNERDRAWFIXED ,LBS_HASSTRINGS is being specified
|
|
|
|
|
How to get message when tab is changed in one MDI multiple tab application?
I have created one multipe tab application with VS2008 feature pack. I hope to add some process when user change the tab by clicking.I derived MainFrame from CMDIFrameWndEx. I use CHTMLView as view base class.
But I failed to find the message for tab swithcing.
Is there someone who can help me?
Thanks in advance.
|
|
|
|
|
Hi,
i have created custom slider using the below code snippet.
m_slider_bar1->Create(WS_CHILD | WS_VISIBLE | TBS_HORZ | TBS_AUTOTICKS , CRect(75, 20, 500, 45), this, IDC_SLIDER1);
now i am able to get the slider in dialog box at run time. but when i click on some where in slider, the slider postion is not coming to the exact location.
always tic values are incrementing by 20. i don't know initially i didn't set any value of the tic positions as well tic increment value.
I gave the min and max values as 0 and 100. Suppose if i clicked at 33 position, the slider is moving to 20th position.
Can any one help me regarding this ASAP, as it is urgent requirement for me.
modified on Tuesday, February 17, 2009 10:17 AM
|
|
|
|
|
venki502 wrote: I gave the min and max values as 0 and 100. Suppose if i clicked at 33 position, the slider is moving to 20th position.
Have you read about the various CSliderCtrl methods to see if any of them are applicable?
http://msdn.microsoft.com/en-us/library/aa313909(VS.60).aspx[^]
How do you know you are clicking at position 33?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hi david,
I have gone through all msdn help regarding my requirement, but still i am not able to get that Can you please help me regarding this..
modified on Tuesday, February 17, 2009 10:17 AM
|
|
|
|
|
The slider doesn't work that way (otherwise they'd call it a Clickbar, not a Trackbar ).
When you click in the track, the control's pagesize setting determines how far
the slider moves.
Here's the docs for the control:
http://msdn.microsoft.com/en-us/library/bb760149(VS.85).aspx[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi mark,
Thanks for your effort on this... One thing i want to make sure before qucik start. Is the track bar and slider both are same ..? If not please direct me how to create track bar dynamically..
if both are similar, do we get exact position of the slider..? if so please give me one example code if possible...
Your help would be apriciated.
modified on Tuesday, February 17, 2009 10:14 AM
|
|
|
|
|
Trackbar is the real name for the "slider" Windows control.
You can get the exact position of the CSliderCtrl with the GetPos() method.
You'll probably have to customize the control if you want to click in the track
and have the slider move to that position.
The control's features, as with other controls, is documented:
Trackbar[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi mark,
I have tried to set TB_THUMBTRACK and TB_THUMBPOSITION controls .... Still i am facing with the same problem. even after setting this i am not getting correct SBCode value in ONHSCROLL evnt message.
I have used SetPageSize function, then i came to know that jumping of slider postion is under control of SetPageSize function. Earlier i told you right..? whenever i have clicked on slider it is incrementing by 20. now if i set the parameter of this function as 5 then every slider position is incrementing by 5 only.
But i am not getting the exact mouse position in the code.
Can you please help me regarding this..?
modified on Tuesday, February 17, 2009 10:14 AM
|
|
|
|
|
venki502 wrote: But i am not getting the exact mouse position in the code.
Correct. The control doesn't work that way. Like I mentioned previously - if you
want the slider position to move to the exact spot you click, then you'd have to
customize the control, perhaps by subclassing the control, intercepting the mouse click
message(s), somehow calculate how the position clicked relates to the new position, and
call SetPos() to set that new position.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|