|
Hey Everybody,
I am trying to get access to my serial port through the CreateFile Method like this
HANDLE portHandle = CreateFile( L"COM3:", GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING,FILE_FLAG_OVERLAPPED,0);
but it keeps giving me an invalid handle. I suspect it is the name of the port. I want to access comm port 3 . Any help would be greatly appreciated.
|
|
|
|
|
Try
CreateFile( "COM3",
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL );
Regards
Anil
|
|
|
|
|
Thank you for your reply but it does not work. For the first parameter it should be L"COM3" instead of just the "COM3" because compiler says that cannot convert char[5] to con. Is there any other solution way?
|
|
|
|
|
Use:
CreateFile("\\\\.\\COM3", ...);
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Dear All,
I am absolutely sorry for this stupid question.
But please explain me in very simple manner!!
But I dont seem to understand CWnd::SubClassWindow(HWND); exactly.
Now here I am subclassing what to what?
Am I subclassing HWND to CWnd ?
Or
Am I subclassing CWnd to HWND ?
What does it mean SubclassWindow exacly.
Here I have many guesses like customised handlers of CWND to work for HWND.
May be subclassing means making one window a child of another which has to be the container and make the child behave more like container . Also make the messages available to Subclassed window which were unavailable before and available messages in more different way.
Which context can I use it?
Please please please somebody explain it in more detailed fashion.
A kid in the block. (
-- Lee
|
|
|
|
|
FROM MSDN:
just an attempt to help u
Call this member function to "dynamically subclass" a window and attach it to this CWnd object.
BOOL SubclassWindow(
HWND hWnd
);
Parameters
hWnd
A handle to the window.
Return Value
Nonzero if the function is successful; otherwise 0.
Remarks
When a window is dynamically subclassed, windows messages will route through the CWnd's message map and call message handlers in the CWnd's class first. Messages that are passed to the base class will be passed to the default message handler in the window.
This member function attaches the Windows control to a CWnd object and replaces the window's WndProc and AfxWndProc functions. The function stores a pointer to the old WndProc in the CWnd object.
Note The window must not already be attached to an MFC object when this function is called.
Example
// The following code shows how to subclass the edit control and list box
// controls inside a combo box. It uses WM_CTLCOLOR for subclassing.
// CSuperComboBox represents the combo box
HBRUSH CSuperComboBox::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
if (nCtlColor == CTLCOLOR_EDIT)
{
//Edit control
if (m_edit.GetSafeHwnd() == NULL)
m_edit.SubclassWindow(pWnd->GetSafeHwnd());
}
else if (nCtlColor == CTLCOLOR_LISTBOX)
{
//ListBox control
if (m_listbox.GetSafeHwnd() == NULL)
m_listbox.SubclassWindow(pWnd->GetSafeHwnd());
}
HBRUSH hbr = CComboBox::OnCtlColor(pDC, pWnd, nCtlColor);
return hbr;
}
void CSuperComboBox::OnDestroy()
{
//unsubclass edit and list box before destruction
if (m_edit.GetSafeHwnd() != NULL)
m_edit.UnsubclassWindow();
if (m_listbox.GetSafeHwnd() != NULL)
m_listbox.UnsubclassWindow();
CComboBox::OnDestroy();
}
|
|
|
|
|
|
I recommend you use the standard CListCtrl from MFC, setting the LVS_EX_CHECKBOXES extended style, using the CListCtrl::SetExtendedStyle(...).
|
|
|
|
|
I noticed this problem a few days ago, but so far I am coming up blank. Also I have been unable to recreate the problem in a scaled down application.
My main window is a dialog created with CreateDialog(), it contains quite a few controls, one of them being a simple EditBox. I am calling DestroyWindow() from WM_CLOSE and it is crashing the app with an "Access violation". Now it only crashes when Chinese charcters are in the mentioned EditBox, and not English. MBCS and UNICODE make no difference.
I have also tried using DialogBox() and EndDialog() yet I have the same problem. Now I should note, Chinese characters are displayed in ComboBoxes, ListViews and Static controls, causing no problems. This only happens when Chinese is typed into the control (using an IME) it does not occur when pasting characters. I have not tried this with any other IME or languages. This will only report an error or crash when running through the debbuger.
I am now going to convert this control to a RichEdit, hopefully the problem will go away. But if anybody has an idea about why or how this is happening I would be glad to know.
|
|
|
|
|
I am using CListrCtrl with Report style. On init dialog i fill the listctrl.
I am Facing One Problem.
Whenever i resize the column the scroll bar disappears.
so plz give the solution for this.
Mahesh
|
|
|
|
|
Mahesh Kulkarni wrote: the scroll bar disappears
This is the standard behaviour of the list control : if all items can be seen inside the client area, the the scroll bar disappears, as you obviously do not need it anymore.
~RaGE();
|
|
|
|
|
I should specify it before. The Vertical scroll bar disappers and which is necessary for me. So plz give any solution.And I agree with you about horizontal scroll bar.
Thanks and Regards.
Mahesh
|
|
|
|
|
You can change the behaveor of CListCtrl only if you derived your own class from it.
|
|
|
|
|
1. What is _afxDBCS, why use it?
2.Why code 1 and code 2 avoid subclassing the IME window and menu window?
3.Windows had UNICODE windows and ANSI windows?
UNICODE window must use UNICODE api to HOOK window message? UNICODE api create the UNICODE window?
---------------------------------
1.<br />
if (_afxDBCS)<br />
{<br />
if (GetClassLong((HWND)wParam, GCL_STYLE) & CS_IME)<br />
goto lCallNextHook;<br />
<br />
LPCTSTR pszClassName;<br />
TCHAR szClassName[_countof("ime")+1];<br />
if (DWORD_PTR(lpcs->lpszClass) > 0xffff)<br />
{<br />
pszClassName = lpcs->lpszClass;<br />
}<br />
else<br />
{<br />
szClassName[0] = '\0';<br />
GlobalGetAtomName((ATOM)lpcs->lpszClass, szClassName, _countof(szClassName));<br />
pszClassName = szClassName;<br />
}<br />
<br />
if (lstrcmpi(pszClassName, _T("ime")) == 0)<br />
goto lCallNextHook;<br />
}<br />
<br />
<br />
<br />
<br />
2.<br />
static ATOM s_atomMenu = 0;<br />
bool bSubclass = true; <br />
<br />
if (s_atomMenu == 0)<br />
{<br />
WNDCLASSEX wc;<br />
memset(&wc, 0, sizeof(WNDCLASSEX));<br />
wc.cbSize = sizeof(WNDCLASSEX);<br />
s_atomMenu = (ATOM)::GetClassInfoEx(NULL, _T("#32768"), &wc);<br />
}<br />
<br />
if (s_atomMenu != 0)<br />
{<br />
ATOM atomWnd = (ATOM)::GetClassLongPtr(hWnd, GCW_ATOM);<br />
if (atomWnd == s_atomMenu)<br />
bSubclass = false;<br />
}<br />
else<br />
{ <br />
TCHAR szClassName[256];<br />
if (::GetClassName(hWnd, szClassName, 256))<br />
{<br />
szClassName[255] = NULL;<br />
if (_tcscmp(szClassName, _T("#32768")) == 0)<br />
bSubclass = false;<br />
}<br />
}
|
|
|
|
|
2DZR8P9EATAHS1N3T4Q4VOL5E9VESAC1WH23
J67K8LLPYBR2UO5B7P35LTE7MIMRNE789SNO
MDSA1N4K66YIU7NO9PRO12BAO5GVLUER24M8
can u find the plain text of this
please i really nid ur help
|
|
|
|
|
Errrr
Is it a code we have to decode ? A kind of secret message from the army or something like that :p ?
|
|
|
|
|
this is the instruction
decipher this, find the plain text
2DZR8P9EATAHS1N3T4Q4VOL5E9VESAC1WH23
J67K8LLPYBR2UO5B7P35LTE7MIMRNE789SNO
MDSA1N4K66YIU7NO9PRO12BAO5GVLUER24M8
yep its my homework
-- modified at 7:48 Wednesday 29th March, 2006
|
|
|
|
|
evita777 wrote: yep its my homework
We will not do the complete homework for you (at least not for free). Start something, and we will help you without any problem. But you have to do the first step.
~RaGE();
|
|
|
|
|
honestly dnt know the first step T_T
but i think its a saying a quote....
|
|
|
|
|
evita777 wrote: yep its my homework
Ar you attending a spy school ?
~RaGE();
|
|
|
|
|
Nope sir....
its my prof. signature one of the boards here...
he challenge us to decipher his SIG
|
|
|
|
|
evita777 wrote: can u find the plain text of this
I can tell you, but then I'll have to shoot you. [Tom Cruise - Top Gun]
If you certify we have a chance to decypher it easily (so no pgp thingy) I can give it a try...
~RaGE();
-- modified at 2:49 Wednesday 29th March, 2006
|
|
|
|
|
this is the instruction
decipher this, find the plain text
2DZR8P9EATAHS1N3T4Q4VOL5E9VESAC1WH23
J67K8LLPYBR2UO5B7P35LTE7MIMRNE789SNO
MDSA1N4K66YIU7NO9PRO12BAO5GVLUER24M8
yep its my homework
|
|
|
|
|
certainly,
as it is not hexadecimal, it is an encrypted message, so, give me the key, and i'll decrypt it for you...
ps: is it an homework ?
|
|
|
|
|
this is the instruction
decipher this, find the plain text
2DZR8P9EATAHS1N3T4Q4VOL5E9VESAC1WH23
J67K8LLPYBR2UO5B7P35LTE7MIMRNE789SNO
MDSA1N4K66YIU7NO9PRO12BAO5GVLUER24M8
yep its my homework
i dunno the key T_T
|
|
|
|