|
Hi.
Is there a way to capture a char from console buffer in a Win 32 Console Application?
I know how to place the cursor on the console screen and replace something but now I wanna know how I get the char from the cursor.
|
|
|
|
|
search for Console here in CP you will many examples that does that.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
Hi,
I am trying to migrate my existing code (c++ - MFC) that works fine in VS6 to VS7.
In my code i have a client server mechanism using the MFC CSocket and Carchive to serialize objects between sides.
This works fine under VS6, but when compiled and run in VS7 the actual serialization process (the storing\reading to\from the archive object) takes much much longer, and after a while it simply get stuck.
when i break in to the the code on the send side i see it is stuck in CSocket::SendChunk and every time it tries to send it gets the WSAEWOULDBLOCK.
(All of the transferred objects are CObject derived ( DECLARE_SERIAL, IMPLEMENT_SERIAL and Serialize overloaded) and contains only MFC CObject derived or CStrings composite object )
Any known issues or ideas?
|
|
|
|
|
im looking for a method,
to find out the account type
of the logged in user,
as in,
administrator or guest priveldges etc
Thanks
|
|
|
|
|
I am having a problem with threads and wonder if anybody can help,
I am spawning a worker thread that updates a linked list that I need access to from the other thread, basically i am passing the instance of the class with the linked list using a struct:
UINT CNetworkMonitoringDoc::CaptureThread(LPVOID pParam)<br />
{ <br />
THREADPARMS* ptp = (THREADPARMS*) pParam;<br />
CPacket* m_capturedPacket = ptp->pPacketInst;<br />
delete ptp;<br />
...<br />
}<br />
The worker thread adds data to the linked list ok but when the orginal thread needs to do something with the m_capturedPacket instance the contained linked list is empty, im guessing the thread is creating its own private copy and working on that; is there anyway to share m_capturedPacket between them?
Cheers
Andy
|
|
|
|
|
I solved this problem by placing a critical section around the usage of the instance of my class
|
|
|
|
|
Hi,
General question:
How can can I obtain a handle to some window only by using its handle, for example: 000004C8
Detailed Question:
How can I obtain a handle to a textbox which resides on a modal dialog, which itself opens as the child of its parent? I should say that I don't know what's the name of that editbox, I can just obtain its handle for example by using spy++.
|
|
|
|
|
Anonymous wrote:
How can can I obtain a handle to some window only by using its handle
HWND hWnd = 0x000004C8;
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
Excuse me, I meant a pointer to its window:
CWnd *pWnd = ...
|
|
|
|
|
pWnd->m_hWnd; gives you the handle of the window.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
You can use CWnd::Attach() to attach a window handle HWND to a CWnd object.
Ant.
|
|
|
|
|
Is it possible to map a CComboBox control to a CString data type? I'm looking in the class wizard, but it only gives int as a possible value so I just want to double check. Thanks.
- Aaron
|
|
|
|
|
int is a verymuch a logical thing to get, coz you can then get corresponding string,and other values from it.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
sry to post this 2x but i figured some ppl wouldnt see it in my other thread.
i get this error:
cannot convert parameter 1 from 'unsigned int' to 'const char *'
Conversion from int type to pointer type requires reinterpret_cast, C-style cast or functions-style cast
for this line of code:
m_port.AddString(ports.ElementAt(i));
How can i fix this?
Thank you
---------------------
And Like The Wind Our Hero Vanishes Off Into The Distance...
|
|
|
|
|
It seems that ports.ElementAt if of type unsigned int (number) and must be of type const char * (string).
Could you provide the ports structure/class declaration/initialization?
|
|
|
|
|
im usinng the stuff the guy gave me in this thread:
Can someone help me with this com port enumarator:
http://www.codeproject.com/script/comments/forums.asp?forumid=1647&df=100&select=776802#xx776802xx
if the link doesnt work it is just a few posts past this one. im using what he gave me not the link i porvided in the origional message
thank you
---------------------
And Like The Wind Our Hero Vanishes Off Into The Distance...
|
|
|
|
|
Ok.
The code in the thread is:
tprintf(_T("COM%d\n"), ports.ElementAt(i));
then, port.ElementAt(i) is a number.
You have to modify your code in the following way (or similar):
char txt[256];
sprintf(txt,"COM%d",ports.ElementAt(i));
m_port.AddString(txt);
Regards
|
|
|
|
|
I need to store the handle of my dialog so that I can pass it to my plug-ins so that they can pass messages back to the calling application. I am doing the following in OnInitDialog(). Will this cause any problems or is this method okay?
BOOL CHTPCCOREDlg::OnInitDialog()
{
...
HWND hMainWindow = AfxGetApp()->m_pMainWnd->GetSafeHwnd();
...
}
|
|
|
|
|
It is safe as long the main window is not recreated.
--
Ich bin der böse Mann von Schweden.
|
|
|
|
|
To use all afx functions do you need MFC linked applications?
|
|
|
|
|
yes
a two cent stamp short of going postal.
|
|
|
|
|
ok, im using this com port enumarator:
http://www.codeproject.com/system/listports.asp
and im haveing trouble using it to list the ports in a list box using MFC. Can someone send me a simple example doing that with this, using VC++ 6 preferably?
thank you, This stupid thing is frustrating me beyond belief lol
---------------------
And Like The Wind Our Hero Vanishes Off Into The Distance...
|
|
|
|
|
In stdafx.h put:
#include <afxext.h>
#include <afxtempl.h>
In EnumerSer.h put:
#ifndef __AFXTEMPL_H__
#pragma message("EnumerateSerialPorts function requires afxtempl.h in your PCH")
#endif
void EnumerateSerialPorts(CUIntArray& ports);
...
Demo.cpp:
#include "stdafx.h"
#include <stdio.h>
#include "EnumerSer.h"
void main()
{
CUIntArray ports;
EnumerateSerialPorts(ports);
_tprintf(_T("The following serial ports are installed on this machine\n"));
for (int i=0; i
|
|
|
|
|
Sorry I forget:
///////////////////////////// Implementation //////////////////////////////////
void EnumerateSerialPorts(CUIntArray& ports)
{
//Make sure we clear out any elements which may already be in the array
ports.RemoveAll();
//Determine what OS we are running on
OSVERSIONINFO osvi;
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
BOOL bGetVer = GetVersionEx(&osvi);
//On NT use the QueryDosDevice API
if (bGetVer && (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT))
{
//Use QueryDosDevice to look for all devices of the form COMx. This is a better
//solution as it means that no ports have to be opened at all.
TCHAR szDevices[65535];
DWORD dwChars = QueryDosDevice(NULL, szDevices, 65535);
if (dwChars)
{
int i=0;
for (;;)
{
//Get the current device name
TCHAR* pszCurrentDevice = &szDevices[i];
//If it looks like "COMX" then
//add it to the array which will be returned
int nLen = _tcslen(pszCurrentDevice);
if (nLen > 3 && _tcsnicmp(pszCurrentDevice, _T("COM"), 3) == 0)
{
//Work out the port number
int nPort = _ttoi(&pszCurrentDevice[3]);
ports.Add(nPort);
}
// Go to next NULL character
while(szDevices[i] != _T('\0'))
i++;
// Bump pointer to the next string
i++;
// The list is double-NULL terminated, so if the character is
// now NULL, we're at the end
if (szDevices[i] == _T('\0'))
break;
}
}
else
TRACE(_T("Failed in call to QueryDosDevice, GetLastError:%d\n"), GetLastError());
}
else
{
//On 95/98 open up each port to determine their existence
//Up to 255 COM ports are supported so we iterate through all of them seeing
//if we can open them or if we fail to open them, get an access denied or general error error.
//Both of these cases indicate that there is a COM port at that number.
for (UINT i=1; i<256; i++)
{
//Form the Raw device name
CString sPort;
sPort.Format(_T("\\\\.\\COM%d"), i);
//Try to open the port
BOOL bSuccess = FALSE;
HANDLE hPort = ::CreateFile(sPort, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
if (hPort == INVALID_HANDLE_VALUE)
{
DWORD dwError = GetLastError();
//Check to see if the error was because some other app had the port open or a general failure
if (dwError == ERROR_ACCESS_DENIED || dwError == ERROR_GEN_FAILURE)
bSuccess = TRUE;
}
else
{
//The port was opened successfully
bSuccess = TRUE;
//Don't forget to close the port, since we are going to do nothing with it anyway
CloseHandle(hPort);
}
//Add the port number to the array which will be returned
if (bSuccess)
ports.Add(i);
}
}
}
|
|
|
|
|
umm u have a few includes there with nothing after them, what do i include?
ty
---------------------
And Like The Wind Our Hero Vanishes Off Into The Distance...
|
|
|
|