|
jipai wrote: LRESULT CALLBACK CBTProc(int nCode, WPARAM wParam, LPARAM lParam)
have u exported the above function?
nave
|
|
|
|
|
Yup.
LIBRARY "My"
EXPORTS
; Explicit exports can go here
StartHook
StopHook
CBTProc
|
|
|
|
|
See Hooks[^] maybe it is some helpful to you
|
|
|
|
|
Thanks for the info. Good to know.
|
|
|
|
|
I hope it solve your problem
|
|
|
|
|
I have created a MFC project in Visual C++ .NET. My goal is read in what is coming from COM port 4.
Here is the entire function below with some comments on what happens:
<br />
BOOL CReadComDlg::ConfigureCOMPort()<br />
{<br />
CString strPort;<br />
BOOL fSuccess;<br />
iCOMPortNumber = 4;
<br />
strPort.Format("COM%d", iCOMPortNumber) ;<br />
<br />
m_hFile = CreateFile( strPort, <br />
GENERIC_READ | GENERIC_WRITE,<br />
(DWORD)NULL,
NULL,
OPEN_EXISTING,<br />
FILE_ATTRIBUTE_NORMAL,<br />
NULL );
<br />
if (INVALID_HANDLE_VALUE == m_hFile)<br />
{<br />
AfxMessageBox( "ERROR 2: unable to connect to COM port." );<br />
return FALSE;<br />
}<br />
<br />
<br />
SetupComm( m_hFile,
(DWORD)2048,
(DWORD)2048);
<br />
<br />
DCB dcb;<br />
fSuccess = GetCommState(m_hFile,&dcb);<br />
<br />
if (!fSuccess) <br />
{<br />
DWORD dError = GetLastError();<br />
<br />
AfxMessageBox ("Error 3: Failed to Get the System Communication Settings.", MB_OK|MB_ICONEXCLAMATION );<br />
return FALSE;<br />
}<br />
.<br />
.<br />
.<br />
.<br />
}<br />
Both functions return error code 995: ERROR_OPERATION_ABORTED = The I/O operation has been aborted because of either a thread exit or an application request.
What does this mean? What am i doing wrong? When I use hyperterminal to setup the connection it works fine. I want to be able to receive data from the COM port. I don't even want to send anything out to the COM port.
If anyone has any suggestions, helpful links, or sample code that would be very helpful. Thank you for your time.
|
|
|
|
|
Hello!
I've made a simple application. When I click a button in mian window a modal popup window shows up:
Ustawienia modalne;
modalne.DoModal();
I want that when I click OK in this modal wnd. it changes a Static Text in main wnd.:
void Modalne::OnBnClickedOk()
{
UpdateData(true);
((CNoweOknoDlg*)m_pParent)->m_text1 = "tekst";
((CNoweOknoDlg*)m_pParent)->UpdateData(false);
OnOK();
}
When I press this button the app crasches
When I made this popup wnd. as modeless using Create() funtion everything is OK. :/
|
|
|
|
|
You should expose the string on your dialog and set the text in your main window. Apart from anything else, your approach makes the two forms tightly coupled for no good reason.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
|
Which bit are you confused by ? Expose a parameter to store the value you want to return, do the rest in your main dialog if the modal call returns OK.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
m_text1 is a CString value that represents static text in mian window. To change it I have to call this:
((CNoweOknoDlg*)m_pParent)->m_text1 = "text"
on button click. I don't have any idea how to do this in a different way.
I'm confused why it works with modeless window.
|
|
|
|
|
OK, so you didn't understand anythign I said ?
I'm not sure why it doesn't work, but either way, when class 1 needs to know about the internals of class 2, they are tightly coupled, and thus cannot work without each other. You're doing this in your OnOK method, so I assume it happens as the dialog closes. so, what you want to do is, the code in CNowkOKnoDlg, your main class, will create this child form and show it. Assuming that "text" is going to become a variable, add a public string variable, then set m_text1 inside the class that holds that variable, and created the dialog that sets it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Christian Graus wrote: Assuming that "text" is going to become a variable, add a public string variable, then set m_text1 inside the class that holds that variable, and created the dialog that sets it
Christian I think even I am misunderstanding you.
Are you suggesting something of the following nature?
CFoo dlg
Dlg.m_text1 = "the test string"
Dlg.Domodal();
Isn’t is safer to
CFoo dlg<br />
<br />
<br />
Dlg.SetMyText("the test string");<br />
Dlg.Domodal();
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|
|
Yes, you are misunderstanding me. Or I'm misunderstanding you. I thought you were setting a string in the main window from the modal dialog. I am saying, set the string in the main window, and expose a property on the dialog to tell you what the string is.
A get method makes more sense than a public property, that much is true. I was just trying to keep it simple.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Christian Graus wrote: I thought you were setting a string in the main window from the modal dialog. I am saying, set the string in the main window, and expose a property on the dialog to tell you what the string is.
Wasn't me, I was just bored perusing the message boards noticed the question and which made no sense (at least to me)
Posting a string back a parent dialog is always a pain, so far I have always found it better to just wait until the modal child closes then follow what you said and use a getter. Shrugs, lol not really my problem I was just confused by the question and responses.
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|
|
What I believe Christian is trying to say here is do something to the following affect.
CFoo Chlddlg<br />
<br />
<br />
if(IDOK == Chlddlg.Domodal())<br />
{<br />
CString str = Chlddlg.GetMyText();<br />
SetWindowText(str);<br />
}
Dont try and post the string back to the parent dialog, let the parent collect it from the child. This protects the inner workings of both classes. GetMyText() could return any variation of data. (this is just a simple example).
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|
|
if you want to change the text of a control you can do this :
void CMdlDlg::OnOkButton()
{
CWnd *parent = this->GetParent();
parent->SetDlgItemText(" control ID ","new text");
}
or if you want to change the main dialog tilte then do this :
void CMdlDlg:;OnOkButton()
{
(this->GetParent())->SetWindowText("new text");
}
|
|
|
|
|
Hi all,
I have a strange and annoying problem with LoadMenu, I use eVC++ 4.0 for mobile apps:
When I call LoadMenu(IDR_RESOURCENAME), it fails, and when call GetLastError it gives me the error code 1814, which in MSDN says "The specified resource name cannot be found in the image file. ", so , whats the problem!! its really annoying.
my code looke like:
mnuCtxt.LoadMenu(IDR_MAIN_TOOL)
Thanx,
Mohammad
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
Ok...
After being annoyed for 4 hours, I solved the problem 2 minutes after I posted this question... just for information the problem is that u cant load a specific menu resource using LoadMenu, u must load a menu bar resource, yeaaaaaaaaaaaaaaaah!!
;P;P;P;P;P
Mohammad
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
can you give me more information about this?
i want to open a menu of a dialog without mouse .
thanks
-- modified at 5:20 Monday 18th September, 2006
|
|
|
|
|
if u want to open it without a mouse u should follow these steps:
1. create a new menu bar using resource editor
2. Define CMenu object and use MyMenu.LoadMenu(IDR_MENUBAR) to load the menu resource.
3. to get a specific popup menu from the bar use: pMenu=MyMenu.GetSubMenu(iIndex);
4. Use the function: TrackPopupMenu to make a popup (context menu).
Regards
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
Hello Everyone, First time posting on this forum but I've been lurking for a long time. I'm starting to teach myself some basic windows programming as I want to get started on DirectX. I can create a window but I'm getting a strange error when I try to run it. The window name is coming out as a series of squares instead of the name. Here's my code:
WNDCLASSEX windowClass = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L,
GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
(LPCWSTR)"Barry's D3D BaseClass", NULL };
RegisterClassEx( &windowClass );
HWND hWnd = CreateWindow( (LPCWSTR)"Barry's D3D BaseClass", (LPCWSTR)"test",
WS_OVERLAPPEDWINDOW, 100, 100, 300, 300,
GetDesktopWindow(), NULL, windowClass.hInstance, NULL );
if( 1 )
{
ShowWindow( hWnd, SW_SHOWDEFAULT );
UpdateWindow( hWnd );
MSG mssg;
PeekMessage( &mssg, NULL, 0, 0, PM_NOREMOVE);
while (mssg.message!=WM_QUIT)
{
if (PeekMessage( &mssg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&mssg);
DispatchMessage(&mssg);
}
else
{
}
}
}
UnregisterClass( (LPCWSTR)"Barry's D3D BaseClass", windowClass.hInstance );
Its a bit of a strange problem and I'm not sure why its happening as its mainly code I've taken from text books and the msdn. Any help would really be appreciated.
|
|
|
|
|
What is obviously a problem in your code is that you cast ASCII strings to UNICODE strings everywhere.
Instead of
(LPCWSTR)"Barry's D3D BaseClass"
you better write
_T("Barry's D3D BaseClass")
If you want to have unicode strings use
L"Barry's D3D BaseClass")
And don't forget to include the header file tchar.h if you haven't already done that.
|
|
|
|
|
Thanks for the reply, I'll try this when I get home and see if that's what's causing the errors.
|
|
|
|
|
Yes that works a treat, So CreateWindowEx takes in UNICODE strings/chars as default and by just using "" I was using ASCII. Then using _T() converts ASCII to UNICODE automatically for you and that's why it works? Great to get the code fix but I'd like to understand why it worked as well.
I'm also trying something else I want to be able to use a string instead of hard coding the string parameter in quotes. Here's the code I want to use:
HWND hWnd = CreateWindow( _T("Barry's D3D BaseClass"), _T(windowName),
WS_OVERLAPPEDWINDOW, 100, 100, 300, 300,GetDesktopWindow(),
NULL, windowClass.hInstance, NULL );
This gives me the follow compile error:
c:\documents and settings\barryod\my documents\visual studio 2005\projects\directx1\directx1\directxbase.cpp(38) : error C2065: 'LwindowName' : undeclared identifier
I'm really not sure what's happening here, any help would be appreciated.
|
|
|
|
|