|
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
|
|
|
|
|
Hello,
I have an Explorer Bar which host web browser control ( IWebBrowser2 ). Now I want to give this window a name so I can access it from other applications such as VBScripts, HTML etc. Perfect examples are IE's main and Search windows. We can access these using _Search and _main.
Any ideas?
regards,
Mahesh
|
|
|
|
|
I wrote an app which has a CScrollView derived class with several instances of an ActiveX control that I also wrote in it. Everything works fine except after a few times scrolling. Then, on Win98SE, the ActiveX controls aren't repainted anymore, the program hangs and a message box saying "A required resource was" pops up (great error
message!). When I debug under Win2K it takes much longer before the program hangs and after a few seconds MSDev comes up with the disassembler window on an int 3 line.
I can't find anything in the KB about "a required resource". I haven't the faintest idea where to look next. This is the last thing I must repair before rolling out the
app to my clients. Does anyone have a clue what this could be?
Thx a lot, Joep
|
|
|
|
|
Well, the problem seems to be with GDI resources. There are a lot of info in MSDN if you search on "GDI resources".
Probably you've allocated resources and never released it.
But GDI resources are limited to all system - if one program will take more and more GDI resources all the running programs could be affected.
This is idea
|
|
|
|
|
I agree - sounds like a resource leak.
Try debugging on the 98 machine - you can use the Accessories | System tools | Resource meter to view usage in more or less real time as you debug.
|
|
|
|
|
I really was very sloppy in this GDI resource rich project, there were several places where I omitted to reselect an old object back into the DC. Thanks very much!
But now we're talking 'bout this subject let me ask something else. Do I have to reselect the previous object each time or is once enough. In other words, should one code like this:
CPen * pOldPen = pDC->SelectObject(MyPen1);
...
pDC->SelectObject(pOldPen);
pOldPen = pDC->SelectObject(MyPen2);
...
pDC->SelectObject(pOldPen);
or is this sufficient:
CPen * pOldPen = pDC->SelectObject(MyPen1);
...
pDC->SelectObject(MyPen2);
...
pDC->SelectObject(pOldPen);
|
|
|
|
|
It is enough to select old object back one time on the exit in every function where you've select your GDI object:
void MyFunc(CDC* pDC)
{
CPen * pOldPen = pDC->SelectObject(MyPen1);
..
pDC->SelectObject(MyPen2);
..
pDC->SelectObject(MyPen3);
..
pDC->SelectObject(MyPen4);
..
pDC->SelectObject(pOldPen);
}
Very important:
don't forget to call ReleaseDC() if you've called GetDC()
|
|
|
|