|
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.
|
|
|
|
|
If you are using SetTimer() with a NULL 3rd argument you are
relying on the message queue sending you the lowest priority message going to tell you about the timer.
Not good. Even worse is if you are busy then no messages are
being processed, hence your timer will never be triggered.
This is why when you click the menu, you caused some processing of the message queue to happen, you get your timer event.
Solution 1:
Pass a callback function for parameter 3. This will be called much more reliably.
Solution 2:
Go multi threaded (beyond the scope of me typing just before going home). There are various articles on codeproject or you could take a look at some of the Platform SDK samples.
I've used both 1 and 2 depending on the situtation (and programming model - Win16 only solution 1 is available).
Cheers
Stephen Kellett
|
|
|
|
|
I have a VC 6.0 SP3 App Wizard generated dll. In the dll's type library I added an enum. The enumerated type is used as an argument in a ClassWizard Generated method. I just changed the return value to be my enum. The basic layout of the odl is below.
[
uuid(...),
helpstring(...),
version(1.0)
]
library MyLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
typedef [uuid(...), v1_enum, helpstring(...)]
enum MyEnum
{
[helpstring(...)] val1 = 1,
[helpstring(...)] val2
}MyEnum;
[ uuid(...) ]
dispinterface MyInterface
{
properties:
//{{AFX_ODL_PROP(CMyInterface)
[id(1)] MyEnum TheType;
//}}AFX_ODL_PROP
methods:
//{{AFX_ODL_METHOD(CMyInterface)
//}}AFX_ODL_METHOD
};
//{{AFX_APPEND_ODL}}
//}}AFX_APPEND_ODL}}
};
When I compile the dll it compiles cleanly and I can see my enum using the OLE-COM object viewer, and if I use the dll in VB I also can see the enumeration, and if I #import the tlb file the enumerations are properly declared. The problem is when I try importing the dll into another appwizard generated exe using ClassWizard. When I do this all my interfaces are imported but ClassWizard ignores the enums I have declared. Is there anyway to get my enums to be declared in the ClassWizard generated class files or do I have to do it myself. Simply importing the tlb is not an option at this point because I would have to rewrite too much of the existing application I am using my dll in.
|
|
|
|
|
I know it might be a ridiculous question but, how to build a DLL with VC++?.
I have a 'simple' program that takes 3 parameters and sends mail through
Lotus Notes (made with the Notes C++ API), I've compiled it with VC++ and it
works perfectly but now I want to turn it into a DLL and I don't know
exactly what changes and additions I have to make to build the app as a DLL
so that the procedure that builds and sends the mail can be invoked from a
different app.
Maybe a very basic DLL source could help me, any help would be welcome,
thanks
|
|
|
|
|
If you're using VC6, you can create DLL projects (MFC or not) from the AppWizard. It will stub out a bunch of functions for you and even include some sample code to show how to export your own stuff.
If you're using VC5 or earlier, you have to do this by-hand. But, it's not difficult. I just use the same template code (3 files, .cpp, .def and a .h) over and over.
-c
|
|
|
|