|
Dear nick,
All you have to do is to go to your dialog in the Resource Editor, and then double-click it to bring up Properties. Then, click the Styles page, and then make sure the
-Title Bar
-System Menu
-Minimize Box
boxes are checked. Make sure to give your dialog a title, and call CWnd::SetIcon() in OnInitDialog() if you want to give your dialog its own icon. i.e.
BOOL CMyDialog::OnInitDialog()
{
CDialog::OnInitDialog();
//...
//...
// Takes care of setting both 32x32 and 16x16 icons
SetIcon(AfxGetApp()->LoadIcon(IDR_MYICON), TRUE);
return TRUE;
}
And voila! Taskbar entry!
Yours,
Brian Hart
|
|
|
|
|
I am trying to find a way to manipulate windows on my computer. I have seen some video driver installation programs that will automatically open the properties box, click on settings, and continue on to install the driver etc.
Do anyone know how they do it?
Pankaj
|
|
|
|
|
To open the screen properties you may execute RUNDLL32 with the name of the exported function from desk.cpl
Syntax for RUNDLL32 is: rundll32 <library>,<exported-function> [function arguments...]
To click on controls you may send mouse messages to the correct window. You may find it with tools like SPY++, look at the class name and the window caption: you have to use those information in a call to FindWindow(). You may use the returned HWND to send messages that don't contain any pointer to data, since you are in another process space.
|
|
|
|
|
I am writing a client that will shutdown the computer. I want it to save as many applications before shutdown. I have tried WM_SAVE, and WM_CLOSE but they don't help much. Any suggestions.
|
|
|
|
|
Has anyone ever implemented a simple user-interface thread, with a dialog that simply has a cancel button? I have done all the steps to create the derived class from CWinThread. I need to be able to create a simple dialog within my derived class, and process it's messages. I have done everything I know, but I am not able to create the dialog inside the thread code, without conflicting with the threads own message pump. This causes a deadlock. This is a class that I need to use other projects as well, so rearchitecting the program to put the computation in a worker thread would be undesirable.
|
|
|
|
|
Can I change size for a Edit Box when I resize Dialog.
And can I chose font for Edit Box?
|
|
|
|
|
Yes, use CWnd::MoveWindow and CWnd::SetFont of your CEdit control in the CDialog::OnSize message handler.
MFC are wrappers for the API.
-Erik
|
|
|
|
|
Can I change size for a Edit Box when I resize Dialog.
And can I chose font for Edit Box?
|
|
|
|
|
Since you haven't specified MFC or API, I'll assume API and then you can apply it to MFC if you need.
In the WM_SIZE handler for your dialog, call SetWindowPos with the HWND of your edit box to change the window position and size. Or you can call MoveWindow with the HWND of your edit box. Move Window is a simpler call.
SetWindowPos documentation
http://msdn.microsoft.com/library/psdk/winui/windows_2blf.htm
MoveWindow documentation
http://msdn.microsoft.com/library/psdk/winui/windows_92nr.htm
Then to change the font of your edit box, you need to use SendMessage with the window message WM_SETFONT.
SetFont documentation.
http://msdn.microsoft.com/library/psdk/winui/controls_7v90.htm
Hope this helps,
-Erik
|
|
|
|
|
Does anybody know how to associate a TKIND_ALIAS with its corresponding TKIND_ENUM using the ITypeInfo interface? Some type libraries are using typedef's for their enums and using the mangled MIDL names for the enumeration. I am trying to get a hold of the "clean" name. The following is an example of a type library that does this (Microsoft Scripting Runtime 1.0).
typedef [public]
__MIDL___MIDL_itf_scrrun_0000_0001 FileAttribute;
typedef enum {
Normal = 0,
ReadOnly = 1,
Hidden = 2,
System = 4,
Directory = 16,
Archive = 32,
Alias = 1024,
Compressed = 2048
} __MIDL___MIDL_itf_scrrun_0000_0001;
Thanks,
Chris
|
|
|
|
|
I need to resize text to fit in a rect. Is there any way to figure out what font size will fit in a rect?
Thanks
Jason Phillips
|
|
|
|
|
You can go the other way (find out the rect needed to hold text of a particular font) with GetTextExtentPoint32(). You can call that and see if the text will fit in your rect, and if not, choose a small font and call the function again.
There's also PathSetDlgItemPath(), which is like calling SetDlgItemText() on a static control, only it will ellipse out the string if needed to make the text fit in the control. That function requires IE4+, though, since it's in shlwapi.dll.
|
|
|
|
|
Hello,
Friday afternoon, ...
Thought I should post this question now:
"How does a programmer open COM 10, 11 or higher"
[ccode]
HANDLE hCom = CreateFile(szPort, GENERIC_READ | GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, 0, NULL));
[/ccode]
It fails when using szPort = "COM10" although I do have the COM Ports available.
Anyone experience in this field?
I am working on NT.
The cards are MOXA CI-134/ISA and C168H/PCI.
I know there is a limitation when working with standard Win32 COM lib on Win 3.11, but does it still apply to WinNT ??
I thought WinNT could handle up to 256 COM ports?
Help!
|
|
|
|
|
Problem solved:
I did get a very usefull reply from Mr Miller from Manaware.
---
NT can do up to 256.
The card manufacturer has not set up the registry and the 'DosNames' for the devices correctly.
There might be other names for those serial ports, but the "COM" file names need special aliases created in the registry.
Some manufacturers fail to add those when they install or initially load the device driver.
Use RegEdit and look for 'SerialPort' or 'Serial Port' and you might find their real names.
So the answer to your quesitons is "Yes, you are right, and the card manufacturer still has some work to do on their device drivers."
---
The problem was solved by using "\\.\COMxx"
In stead of opening "COMxx" (where xx is is the number)
|
|
|
|
|
Any good links or articles on monikers??
regards,
Mahesh
|
|
|
|
|
Is any body know some articles or links about "Pluggable Protocols"??
regards,
Mahesh
|
|
|
|
|
Hi All,
I used the following code. But it appears that my code in the OnTimer function is never executed.
The strangest thing is that if I click the menu ,so it drops down, the timer is executed! And as soon as I pull up the menu again, the timer stops!
Can anyone give me a explaination for this? Thanks a lot.
void CMyDialog::OnMyFunction()
{
...
SetTimer(1, 500, NULL);
...
}
void CMyDialog::OnTimer(UINT nIDEvent)
{
... // my code}
}
|
|
|
|
|
Have you a handler for WM_TIMER in message map?
BEGIN_MESSAGE_MAP...
...
ON_WN_TIMER()
END_MESSAGE_MAP
try to use
VERIFY(SetTimer(1,500,NULL)); to make sure you've set timer
|
|
|
|
|
Yes, I have the handler in message map.
what does the VERIFY() should do? because nothing different happened when I add it.
The line of code right before the SetTimer(1,500,NULL) is:
MCIWnd(hMCI); // plays a movie
This shouldn't affect anything, should it? I know that MSDN says "The WM_TIMER message is a low-priority message."
I have another smaller app that also dialog-based that does that: plays a movie while activating the timer.
Thanks.
|
|
|
|
|
VERIFY does make sure the function returns value non-zero, otherwise it popups assertion dialog box in DEBUG, in Release does nothing.
You, probably, right speaking about low-priority. You may create separate thread for handling WM_TIMER.
|
|
|
|
|
I never use thread before (and it sounds&seems confusing)
Could you please post a small sample code on how to create, call, and destroy a simple thread on an MFC dialog-based?
Thanks a lot in advance.
|
|
|
|
|
VERIFY does make sure the function returns value non-zero, otherwise it popups assertion dialog box in DEBUG, in Release does nothing.
You, probably, right speaking about low-priority. You may create separate thread for handling WM_TIMER.
|
|
|
|
|
Try running it through the debugger and trace your code. Something might make itself clear to you. ~Andy
|
|
|
|
|
I did some more digging and found something:
In the project, I create an owner draw button. What I want to do is move this button while the movie is playing. Therefore I add this line on OnTimer:
GetDlgItem(IDC_MY_IMAGE_BUTTON)->MoveWindow(newX, newY, newWidth, newHeight, true);
And it works (it moves while the movie playing). But I also want to draw an image on the button, so I created a new class CMyImageButton, derived from CButton class.
And as soon as I associated the owner draw button variable to CMyImageButton class, the OnTimer stop working.
Any idea why?
Thanks.
|
|
|
|
|
Many moons ago I remember having all sorts of trouble with SetTimer and seem to remember thatI ended up fixing them by changing the event number ie
SetTimer(111,500,NULL);
I never worked out why this worked and 1 didn't but it may be worth a try in your case.
|
|
|
|