|
|
Any way, that allows you to detect end of the parameter list is acceptable. With the NULL backstop is only one disadvantage which comes to mind when you really need to pass some NULL as a valid value to one of normal parameters.
|
|
|
|
|
I created a Modaless dialog from my application, how can I detect that the dialog has lost focus (ex when the user clicks within the parent window and the dialog box is still there. I need this b/c without it new Modaless dialog boxes can be created with the existing one there.
-Steven Hicks
CPACodeProjectAddict
|
|
|
|
|
One solution is to add a handler for WM_KILLFOCUS.
Kuphryn
|
|
|
|
|
who to flush the receivebuffer of the serial interface (com1)
|
|
|
|
|
How are you currently reading from it?
|
|
|
|
|
#ifndef MESSGERAETE_H
#define MESSGERAETE_H
#include "windows.h"
class Messgeraete{
public:
Messgeraete();
~Messgeraete();
void takeValues();
double getValue(int value);
void stopThread();
//-1: Messung wurde abgerochen, 0 keine gütligen Werte, 1 gültige Werte wurden gelesen
int getMessflag();
static DWORD messenThread(LPVOID);
private:
HANDLE h_com;
HANDLE h_messThread;
DCB dcb;
COMMTIMEOUTS cto;
double value1, value2;
int messflag;
};
#endif
Messgeraete::Messgeraete(){
messflag=0;
h_com = CreateFile("COM1", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0 , NULL);
DCB dcb_neu;
COMMTIMEOUTS cto_neu;
GetCommState(h_com, &dcb);
GetCommState(h_com, &dcb_neu);
dcb_neu.BaudRate = 9600;
dcb_neu.ByteSize = 8;
dcb_neu.Parity = NOPARITY;
dcb_neu.StopBits = ONESTOPBIT;
SetCommState(h_com, &dcb_neu);
GetCommTimeouts(h_com,&cto);
GetCommTimeouts(h_com,&cto_neu);
cto_neu.ReadTotalTimeoutConstant=0;
cto_neu.ReadTotalTimeoutMultiplier=0;
SetCommTimeouts(h_com,&cto_neu);
}
Messgeraete::~Messgeraete(){
SetCommTimeouts(h_com,&cto);
SetCommState(h_com, &dcb);
CloseHandle(h_com);
}
DWORD Messgeraete::messenThread(LPVOID lparam){
Messgeraete *mp = (Messgeraete*)lparam;
int i;
unsigned long nBytesRead1,nBytesRead2;
char inbuffer1[13];
char inbuffer2[13];
char temp[9];
temp[8]=0;
ReadFile(mp->h_com, &inbuffer1, 13, &nBytesRead1, NULL);
ReadFile(mp->h_com, &inbuffer2, 13, &nBytesRead2, NULL);
// CString str;
// str.Format("%s\n%s",inbuffer1,inbuffer2);
// AfxMessageBox(str);
for(i=0;i<8;i++) temp[i]=inbuffer1[i+4];
mp->value1=atof(temp);
for(i=0;i<8;i++) temp[i]=inbuffer2[i+4];
mp->value2=atof(temp);
if(inbuffer1[0]=='9'){mp->value1=-1;AfxMessageBox("Messschieber ist nicht eingeschaltet oder nicht richtig angeschlossen");}
if(inbuffer2[0]=='9'){mp->value2=-1;AfxMessageBox("Messuhr ist nicht eingeschaltet oder nicht richtig angeschlossen");}
mp->messflag=1;
return 0;
}
void Messgeraete::takeValues(){
messflag=0;
h_messThread=CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)messenThread, (LPVOID)this, 0, NULL);
}
double Messgeraete::getValue(int value){
if (value==1) return value1;
else return value2;
}
void Messgeraete::stopThread(){
DWORD dw;
GetExitCodeThread(h_messThread, &dw);
TerminateThread(h_messThread, dw);
value1=value2=-1;
messflag=-1;
}
int Messgeraete::getMessflag(){ return messflag; }
|
|
|
|
|
|
doesn't work
in msdn is writte:
If hFile is a handle to a communications device, the function only flushes the transmit buffer.
I want to flush the receive buffer
any ideas?
|
|
|
|
|
Hi David,
Solution was this command
Thanks for you help
PurgeComm(h_com,PURGE_RXCLEAR);
|
|
|
|
|
yes, the debugging version is working okay, and the release version crashed.
It's a SDI project. After the release version run for about 5 seconds, this error message pop up:
"First-chance exception in MyApp.exe: 0xC0000005: Access Violation."
The call stack is:
CWnd::AttachControlSite(CWnd * const 0x010b7b2c {CMapPtrToPtr}, CHandleMap * 0x010b7b28) line 420
CWnd::FromHandle(HWND__ * 0x00060aaa) line 293
CWnd::GetOwner(const CWnd * const 0x010b7b2c {CMapPtrToPtr}) line 35 + 22 bytes
AfxGetParentOwner(HWND__ * 0x00050ad2) line 2141 + 7 bytes
CWnd::GetTopLevelParent(const CWnd * const 0x010b7b2c {CMapPtrToPtr}) line 2157 + 6 bytes
CWinThread::PreTranslateMessage(CWinThread * const 0x010b7b2c {CMapPtrToPtr}, tagMSG * 0x004751d0 {msg=0x00000118 wp=0x0000ffff lp=0xa00258ae}) line 680 + 7 bytes
CWinThread::PumpMessage(CWinThread * const 0x010b7b2c {CMapPtrToPtr}) line 848 + 17 bytes
CWinThread::Run(CWinThread * const 0x010b7b2c {CMapPtrToPtr}) line 487 + 7 bytes
CWinApp::Run(CWinApp * const 0x010b7b2c {CMapPtrToPtr}) line 399 + 7 bytes
AfxWinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 0x00000000, char * 0x00133476, int 1) line 49 + 7 bytes
WinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 0x00000000, char * 0x00133476, int 1) line 30
TCSTATUS! WinMainCRTStartup + 224 bytes
any hint?
Thank you a lot for any help!
|
|
|
|
|
The usuals, check for un-initialized variables, bad conditions in if, bad loops, ...
Give your project a level-4 warning level compile to see if the compiler can find the obvious things.
Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
|
|
|
|
|
See if this helps:
http://flounder.com/debug_release.htm
|
|
|
|
|
Thank you guys.
I used a class for joystick support. I think it's it which couldn't survive the release. I used it in another app, which I couldn't build release version either.
It's using DirectIO tech. Any idea how to debug such stuff?
|
|
|
|
|
lucy wrote:
It's using DirectIO tech. Any idea how to debug such stuff?
Never heard of it. Your best bet is to create a small application that demonstrates the problem. Once the reproducible code is as small as possible, try posting it here for help.
|
|
|
|
|
I am trying to put my own ActiveX on CFileDialog.
When I put on it, all the sudden this CFileDialog
doesn't start up. some can help me to solve this?
Thanks in advanced.
Shinay
|
|
|
|
|
I have an MFC Extension DLL and I load it into memory using LoadLibrary function. Then I call a method of this dll, which creates a modeless dialog.
My problem is I would like to free this dll when the user closes the dialog.
But I am not sure how to do this.
Do I have to unload a dll from the main program or can I unlod the dll from within the dll itself.
If I have to unload it from the main program how can I notify the main program.
Thank you
Orcun Colak
|
|
|
|
|
There are several solutions. One solution is messages. Send a message to the main thread and have it unload the DLL.
Kuphryn
|
|
|
|
|
Be carefull here: if your DLL is proper Extension DLL and you are unloading it from memory: As I recall, MFC doesn't have proper cleanup in this case: pointer to one of your DLL classes may still be registered in main EXE linked list. So, check this out: I just recall having alot of troubles related to this. Maybe MFC has been fixed since then though.
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
Hello all
I'm establising a database connection to sqlserver using ADO. I was able to successfully establish connection to sqlserver and after I'm executing a procedure which returns a recordset. But I'm not able to read from that record set. It was always giving "-1" when I use Recordset.GetRecordCount().
The code I used to perform the connection is as follows
m_Connection->Open((char*)m_ConnectionString, L"", L"", adModeUnknown);
m_Command->ActiveConnection=m_Connection;
m_Command->CommandText = ProcName;
m_Command->CommandType = adCmdStoredProc;
m_Recordset=m_Command->Execute(NULL,NULL,adCmdUnknown);
Now if I use
m_Recordset.GetRecordCount() gives -1;
Is there anything wrong with the above code? Please help me in reading from the recordset.
Thanks for your help
Hari.
|
|
|
|
|
Hi,
I have a dialog class in my MFC project. How can I delete it peacefully?
Ehsan Behboudi
|
|
|
|
|
Try dropping its files from the project.
Or you could even try hitting 'DEL' on the class in class view. (I think this works, but I am not absolutly sure, and can't test just now.)
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
I want ActiveX to be rewritten fast -
for that I want to delegate that aspect to the system
from it's onDraw(),
that is - it would be suffitient to rewrite externally it's region,
like control is unchangeble.
It redraws self each mouse window move over it or
sometimes over container,
it is too slow and uneed!
Drawing is some background vased - that is mean - complex.
But views is not changing really.
I think this can be done by seting
OLEMISC_ACTIVATEWHENVISIBLE flag to FALSE,
but where and how to do it?
I wriye ATL ActiveX control like MSDN sample AtlButton.
thanks you.
|
|
|
|
|
These miscellaneous flags are stored in the registry.
You should have a .rgs file for your control which contains the registry entries to be created when it self-registers. Under the control's CLSID entry, you'll see a MiscStatus entry. It's a bitmask of all the values that are set. Typically the ATL wizard generates a value of 131473, which is hex 0x20191, which indicates the flags OLEMISC_SETCLIENTSITEFIRST , OLEMISC_ACTIVATEWHENVISIBLE , OLEMISC_INSIDEOUT , OLEMISC_CANTLINKINSIDE and OLEMISC_RECOMPOSEONRESIZE .
I'm not convinced that unsetting this flag will help, though - what it will do is only activate the control when it has the focus, relying on a cached image representation of the control the rest of the time.
You might be better off trying to optimise your drawing, e.g. minimise the number of drawing operations, following the batching rules mentioned in the GdiFlush[^] documentation, doing as much work with the selected object as possible (changing objects, for example, pens, causes a batch flush). If your control is windowed, consider making it windowless (draws into the parent window's device context) saving a small amount of time.
|
|
|
|
|
I want to minimize drawing - but -
external functionality looking too much efficient - that is already
moves windows and commands to repaint-
to pver emulate this need much work - this is looking unneed
if in the system already there is it's native (external moving windows) ability to do this.
Do you know how to activate this ?
|
|
|
|
|