|
There was no WinAPI forum, so I thought this was the closest fit for which forum this post should be applied.
I have written some very simple (non-overlapped) windows (NT/2K) serial port drivers. The definitions to be used for baud rates have two different values, CBR_56000 and CBR_57600 (in addition to the others).
I notice that using a terminal emulator to test (Hyperterminal) set at 57600, I can connect to it fine using CBR_56000, but not CBR_57600. This seems a little bizarre.
I'd appreciate it if anyone can explain this?
There are only 10 types of people in this world....those that understand binary, and those that do not.
|
|
|
|
|
Is it me who's blind and retarded, or is it impossible to add resources to .NET projects (C# in this case) as you would in a C++/MFC project?
All I want to do is to add icons/images and have them compiled into the assembly...
Nevermind, I found some articles to read in MSDN.
--
"And God said, Let us make man in our image"
|
|
|
|
|
How can I read a default value (HKCR\http\shell\open\command)? I tried passing an empty strign with RegQueryValueEx but it didn't work!
Thanks!
---------------
Tired of Spam? Introducing InboxShield® for Microsoft® Outlook®
http://www.edovia.com
|
|
|
|
|
DWORD dwStatus,dwcbData=4096,dwType; HKEY hKey;
BYTE buffer[4096];
dwStatus = RegOpenKeyEx(HKEY_CLASSES_ROOT,"http\\shell\\open\\command", 0, KEY_READ, &hKey);
RegQueryValueEx(hKey,"",0,&dwType,(LPBYTE) buffer,&dwcbData);
works nicely for me.
#include <beer.h>
|
|
|
|
|
How can I create a folder programmatically from my MFC 6 application?
Thanks so much,
n
|
|
|
|
|
With CreateDirectory , surprisingly enough
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
Help for a newbie!
I'm debugging a console application. The app uses several cout
statements to display info in the output window. However, when
single stepping through the program the output window is not
updated as each cout is executed. The output window is updated
when the end of the program is reached. Is there a way to cause the output window to be updated as each cout is executed. Thanks.
|
|
|
|
|
cout<<endl should flush to the console.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
Hi folks,
I am currently facing the problem as specified in the topic question. All I need to do is logon to a remote machine in the LAN and start an executable. The catch is I cannot use sockets. CreateProcessWithLogonW allows me to logon to the domain on my own machine using a different user id and password but how to achieve the same on a remote machine. Is it possible? If yes, kindly guide me.
ciao
Aravindan Premkumar
|
|
|
|
|
Hello guys,
Where can I find a good implementation of IClassFactory2 , whitout using that DECLARE_CLASSFACTORY2(CMyLicense) macro, to perform licensing capabilities to my software?
Thanks in advance,
Raphael Amorim Dantas Leite
VC++, VB, Java, .NET and eMbedded Programmer
|
|
|
|
|
What's wrong with checking out the code which the macro expands to?
--
"And God said, Let us make man in our image"
|
|
|
|
|
hello,
I've developed a programm that write to a file(using CFile). Now if i run it on a machine withoud Visual C++ installed, the programm crashes... can anyone tell me why?
if checked all dependencies and none are missing(i think)...
thanks in advance
[]D [] []D []
|
|
|
|
|
How did you check the dependencies? Did you use run option on depends.exe?
|
|
|
|
|
Why not setup a remote debugging session?
Then you can trace through your code and see where/when/why it fails.
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
Hi
I was wondering if it was possible to create another window in addition to the main window that comes up. It will come up when a menuitem is clicked on the main window. I'm just wondering how I would write the int WINAPI WinMain and LRESULT CALLBACK WndProc when I already have them up because of the original window.
Thanks
Regards
Nitin
|
|
|
|
|
You can use the same WndProc (or as many as you like) for each main (WS_OVERLAPPED) window.
The only thing to be careful of is to not do PostQuitMessage () in response to a WM_DESTROY
in one of the main windows. This is one of the few times that globals come in handy.
You could have a global counter, and set it to 0 in your WinMain.
Then increment in each top level WM_CREATE, and decrement in WM_DESTROY. Just post the
quit message if the counter goes back down to 0.
Or maybe a menu item says "File | Exit All" for example...
Iain.
|
|
|
|
|
Thanks for your quick reply.
But, what would I do about this function and the accelerators?
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
MSG msg;
HACCEL hAccelTable;
// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_TRIAL, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_TRIAL);
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int) msg.wParam;
}
Thanks
|
|
|
|
|
Do I just add this function ATOM MyRegisterClass to the winapi main as well? Or do I have to make another ATOM MyREgisterClass(hinst) ?
Thanks
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_TRIAL);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = (LPCTSTR)IDC_TRIAL;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
return RegisterClassEx(&wcex);
}
|
|
|
|
|
You don't have to make another RegisterClass -like functions unless you need another classes for the windows you create from your application. Just multiplicate the InitInstance call:
for (int i=0; i<number_of_windows; i++)
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
} and the message queue:
for (i=0; i<number_of_windows; i++)
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
} Leave the PostQuitMessage call untouched; thus the windows will post WM_QUIT messages for number_of_windows times and the application will exit only when the last window will be closed.
rechi
|
|
|
|
|
Thanks rechi
But do I still create both the windows in the same function initInstance? Because I needed the button on the original window to bring up this next window...don't I need to put the create Window function under the case IDC_BUTTON ?
Regards
Nitin
|
|
|
|
|
I'm sorry, i read your first post superficially - the end of the working day is gettin' closer for me
Now, forget what i said and put
LONG lCount=1; as a global variable to keep the number of open windows. Replace the message loop as follows:
LONG lMan=0;
do
{
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
InterlockedDecrement(&lCount);
InterlockedCompareExchange((void **)&lMan, (PVOID)1,
(PVOID)lCount);
} while (!lMan);
and insert:
case IDC_BUTTON:
InitInstance(hInst, SW_SHOW);
InterlockedIncrement(&lCount);
break;
in the window procedure's code. It's best to run it step by step with a breakpoint in the position i mentioned.
Good luck, i'm melting myself towards the offline world now...
rechi
|
|
|
|
|
How do I set the default folder for the CFileDialog ? I thought "must be easy - just set the current directory", but it doesn't seem to use the folder set by ::SetCurrentDirectory()
Thanks in advance!
|
|
|
|
|
You can specify the starting directory in the OPENFILENAME member of you CFileDialog. The OPENFILENAME's member lpstrInitialDir points to the corresponding directory.
|
|
|
|