|
Hi CG,
Richter's advice was that we should use _beginthreadex if we plan on using CRT functions inside our thread. But if we are not, then we might as well use the API calls to start threads
Nish
If I am awake and my eyes are closed, it does not necessarily mean that I am thinking of naked women.
|
|
|
|
|
I am testing a program i wrote on a win98 system on a
Win2k O.S. and am having troubles with the serial communications.
When executing the program win2k is crashing in the
'WriteFile' function, which leads me to believe there
is something wrong with the flow control or handshaking.
But why would it all work fine on 98 and not 2K.
Does anyone know of any defaults etc that win2k may be setting
or looking for that 98 does not.
p.s. I have set up my DCB as follows
dcb.DCBlength = sizeof(DCB);
dcb.BaudRate = CBR_9600;
dcb.ByteSize = 8;
dcb.StopBits = ONESTOPBIT;
dcb.fParity = NOPARITY;
dcb.fBinary = TRUE;
dcb.fDtrControl = DTR_CONTROL_DISABLE;
dcb.fRtsControl = RTS_CONTROL_DISABLE;
dcb.fTXContinueOnXoff = FALSE;
dcb.fOutX = FALSE;
dcb.fInX = FALSE;
|
|
|
|
|
Can't see anything wrong, but heres an example of some code for a serial port which I have used successfully on 95/98/NT/2K/XP
SECURITY_ATTRIBUTES sa ;
sa.nLength = sizeof(SECURITY_ATTRIBUTES) ;
sa.lpSecurityDescriptor = NULL ;
sa.bInheritHandle = true ;
m_hSerialPort = CreateFile((LPCTSTR)m_csCommPortName,
GENERIC_READ | GENERIC_WRITE,
0,
&sa,
OPEN_EXISTING,
0,
0) ;
if (m_hSerialPort != INVALID_HANDLE_VALUE)
{
m_bOpen = true ;
if (!GetCommState(m_hSerialPort, &m_dcb))
{
error.LoadString(IDS_CAVRO_DCB) ;
DisplayText(error) ;
}
else
{
FillMemory(&m_dcb, sizeof(DCB), 0) ;
m_dcb.DCBlength = sizeof(DCB) ;
m_dcb.BaudRate = CBR_9600 ;
m_dcb.ByteSize = 8 ;
m_dcb.Parity = NOPARITY ;
m_dcb.fParity = false ;
m_dcb.StopBits = ONESTOPBIT ;
m_dcb.fDtrControl = DTR_CONTROL_DISABLE ;
m_dcb.fOutxCtsFlow = false ;
m_dcb.fDsrSensitivity = false ;
m_dcb.fTXContinueOnXoff = true ;
m_dcb.fOutX = false ;
m_dcb.fRtsControl = RTS_CONTROL_DISABLE ;
m_dcb.fAbortOnError = false ;
if (!SetCommState(m_hSerialPort, &m_dcb))
{
error.LoadString(IDS_CAVRO_STATE) ;
DisplayText(error) ;
}
if (!SetCommMask(m_hSerialPort, EV_RXCHAR))
{
error.LoadString(IDS_CAVRO_MASK) ;
DisplayText(error) ;
}
COMMTIMEOUTS timeouts ;
timeouts.ReadIntervalTimeout = MAXDWORD ;
timeouts.ReadTotalTimeoutConstant = 0 ;
timeouts.ReadTotalTimeoutMultiplier = 0 ;
timeouts.WriteTotalTimeoutConstant = 0 ;
timeouts.WriteTotalTimeoutMultiplier = 0 ;
SetCommTimeouts(m_hSerialPort, &timeouts) ;
}
}
It may have something in it you have missed.
Roger Allen
Sonork 100.10016
If I'm not breathing, I'm either dead or holding my breath.
A fool jabbers, while a wise man listens. But is he so wise to listen to the fool?
|
|
|
|
|
Ok, I am playing around with the new HTML stuff in VS.NET/MFC7, and ditched the CDHTMLDialog, and using the CDHTMLView which I snagged from an article here.
However, what I would like to have is have a MFC ListControl in the bottom portion of the screen, the obvious answer would simply be to have a splitter window. However, I would like to have it look like its imbeded in the over all GUI and not plopped down on the bottom.
I have it so the list control displays when I click on a link, however any other link I click, it instantly vanishes, and when I click on the button again, it wont re-display.
How would I go about having it remain visible, and avoid flickering problems?
|
|
|
|
|
Possibly:
m_wndList.SetWindowPos(&CWnd::wndTopMost, 0,0,0,0, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE);
Developers that like shiny objects also dig case mods and scratch-and-sniff stickers. Klaus Probst, The Lounge
|
|
|
|
|
Unfortuantly, that did not work. Hrmmm
|
|
|
|
|
The function I have which is run when I click an HTML link, is only called the first time I click it, and wont do it any other time...
|
|
|
|
|
How can I change the size of a dialog toolbar before it is created.
Example:
I want to change IDD_DIALOG 's size programatically before it is used to create a toolbar.
I hope that makes sense, Thanks if you can help.
- Matt Newman / Windows XP Activist
-Sonork ID: 100.11179:BestSnowman
†
|
|
|
|
|
Can;t you just resize the dialog just before you create the toolbar. I presume you do that in WM_INITDIALOG handlwer
Nish
If I am awake and my eyes are closed, it does not necessarily mean that I am thinking of naked women.
|
|
|
|
|
There is no class assigned to IDD_DIALOG , I was curious if I could change the resource dimensions on it's resource ID (it is blank)
- Matt Newman / Windows XP Activist
-Sonork ID: 100.11179:BestSnowman
†
|
|
|
|
|
Any ideas or examples?
Thanks!
|
|
|
|
|
I have already found one.
|
|
|
|
|
Why don't you share it with us?
Best regards,
Alexandru Savescu
|
|
|
|
|
Hey, I found these just exactly in www.codeproject.com
http://www.codeproject.com/dll/hooks.asp
http://www.codeproject.com/dll/keyboardhook.asp
|
|
|
|
|
For Visual Studio .
Scratch
|
|
|
|
|
Programmatically?
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment
Manually?
System Properties/Advanced Tab
Jeremy L. Falcon
"The One Who Said, 'The One Who Said...'"
<nobr>
Homepage : Feature Article : Sonork = 100.16311
|
|
|
|
|
dll_file.H
extern "C"
{
<code>__declspec</code>(<code>dllexport</code>) <code>bool</code> func1(<code>bool</code> a);
<code>__declspec</code>(<code>dllexport</code>) <code>bool</code> func2();
} dll_file.cpp
<code>__declspec</code>(<code>dllexport</code>) <code>bool</code> func1(<code>bool</code> a)
{
<code>int</code> x=0;
x=x+1;
return true;
}
<code>__declspec</code>(<code>dllexport</code>) <code>bool</code> func2()
{
<code>int</code> x=0;
x=x+1;
return <code>true</code>;
}
compiling - OK
LoadLibrary - OK
GetProcAddress(* both func1 & 2 *) - OK
calling func2 - OK
calling func1 - fails while returning back to the app
the error is:
The value of ESP was not properly saved across a function call.
Please
HH EE LL PP
Thank you for reading all this....
Hope u have the answer
|
|
|
|
|
ESP is the 32-bit stack pointer CPU register that points to locations in the stack segment. Where's the stack being used here? Look at your parameters.
So, we know ESP didn't get a value it expected. Why? I dunno for sure, but you are using C linkage and C doesn't support a bool type. I'm "guessing" the compiler doesn't care because it's being compiled as C++. This may work, I just haven't tried it yet. Also, fun1() is not referencing its param in the first place. Trying using it in the function and change it to an int -- just for testing.
Jeremy L. Falcon
"The One Who Said, 'The One Who Said...'"
<nobr>
Homepage : Feature Article : Sonork = 100.16311
|
|
|
|
|
The problem is in calling convention.
I guess that you use (CALLBACK *)(bool) or (__stdcall *)(bool) calling convention.
This is wrong in the case then you use "C" declaration of functions (extern "C" {}).
Coz in "C" declaration the caller should clean up stack but not callee.
So you should use (FAR *)(bool) or (__cdecl *)(bool) calling convention in case with "C" declaration.
P.S. Try to avoid using other types in function argument but integer. Coz they will be converted to integer anyway.
Have fun.
|
|
|
|
|
How do I close a view window problematically?
Do i have to close its frame window and it in some specific order?
Anon
|
|
|
|
|
Once you have a pointer to the view, just do:
pView->SendMessage ( WM_CLOSE );
--Mike--
Actual sign at the laundromat I go to: "No tinting or dying"
Like the Google toolbar? Then check out UltraBar, with more features & customizable search engines!
My really out-of-date homepage
Big fan of Alyson Hannigan and Jamie Salé.
|
|
|
|
|
Hi, Mike!
I encountered the same problem recently. You method wont work in a MDI application. Nothing will happen after you send WM_CLOSE.
Try the following step to verify by yourself:
1. Create a MDI application called "Tst" using AppWiz;
2. Craete a CloseView menu item under View menu
add response codes to this menu item in the CTstView class.
void CTstView::OnViewCloseview()
{
// TODO: Add your command handler code here
SendMessage(WM_CLOSE);
}
3. compiled it & run. Open some views, then click on CloseView menu item. You will see, nothing happen.
Is there anybody have a solution for this?
Comments & suggestion are greatly appreciated!
Wayne King
17 April 2002
|
|
|
|
|
hello!
I have a question: is it possible to take a CDC and pass it's display to a CBitmap class? For example, I would like to draw things in a window (using Rectangle, Ellipse and such) and then get the pixels in that window to CBitmap.
Once again, my apologies if this is a dumb question, I don't know much about this matters
marcela bovio
|
|
|
|
|
You can create a CBitmap and then select it into the DC. you could then use the CBitmap for whatever you wanted (as far as I'm aware).
CDC m_memDC;
CBitmap m_bmp;
CClientDC DC(this);
m_memDC.CreateCompatibleDC(&DC);
m_bmp.CreateCompatibleBitmap(&DC, m_ScreenSizeX, m_ScreenSizeY );
m_memDC.SelectObject( &m_bmp );
then draw into the m_memDC, and the m_bmp will be drawn to. I think you may need to unselect the CBitmap afterwards, so windows can free the GDI resources, but I'm not too sure.
Hope that helps,
Pete
|
|
|
|
|
Following code gives assertion fail under VS 7 (sometime with 6)
void StringFromWide(const wchar_t* pwch, int cch, char *psz, int szLen)
{
if(cch == 0) {
cch = wcslen(pwch);
// TODO it will display only first four char
}
if(cch > szLen) cch = szLen;
WideCharToMultiByte(CP_ACP, 0, pwch, cch, psz, cch, NULL, NULL);
psz[cch] = '\0';
}
As workaround I'm using following code
void StringFromWide(const wchar_t* pwch, int cch, char *psz, int szLen)
{
size_t szt;
if(cch == 0) {
szt = wcslen(pwch);
cch = sizeof(szt) ;// but this will retrieve four chars only
}
if(cch > szLen) cch = szLen;
WideCharToMultiByte(CP_ACP, 0, pwch, cch, psz, cch, NULL, NULL);
psz[cch] = '\0';
}
What is missing here?
|
|
|
|