|
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()
|
|
|
|
|
Yup - and you might also look at SaveDC() and RestoreDC().
|
|
|
|
|
I have a dialog with a listbox. For some invocations of the dialog, I want the listbox to be multi-selection and for other invocations, the listbox should be single-select.
In OnInitDialog(), I used ModifyStyle() to change the selection style. But this did not work.
Is there a solution without subclassing CListBox?
|
|
|
|
|
There are 2 possible ways -
1) Derive your class from CListBox with multiselect style and handle selection event (mouse and keyboard) depends on the mode you have - allowing or dissallowing to select more then 1 item.
2) Every time you changing multiselect style - recreate control.
|
|
|
|
|
I did not make myself sufficiently clear. I have a list box in a dialog. Depending on an argument to the constructor of the dialog, I want to make this list box either single selection or multi-selection. However, once the selection style is set, It will not change for till the dialog is dismissed. In the resource editor, I'll set selection type to be 'single selection'. Depending on the argument to the constructor, I want to modify the selection type to 'Multi-Selection'. Is there a simple way of doing this without recreating the ctrl or deriving a class from CListBox.
I tried ModifyStyle(0, LBS_MULTIPLESEL) in the OnInitDialog() of the dialog. This did not work. Hence this post.
|
|
|
|
|
"Depending on an argument to the constructor of the dialog..." Well, if you have dialog on the resource it will have the styles specified in resource editor, how can you change it? It doesnot create dialog like window. It loads it from the resource.
Well, another option - create 2 dialogs in resource editor with different styles and load appropriate dialog from the resource.
|
|
|
|
|
In a ATL Com DLL Project, for every component, an RGS file is generated.Also, a TLB file is generated when an IDL file is compiled.This TLB file is referred in the RC file of the ATL Com project.If I use a RGS file to register a component explicitly, Do I still need to include the TLB file as part of the project?
OR, can i delete the reference to the TLB file from the RC file and remove the TLB file from the project?
|
|
|
|
|
Hi,
The RGS and TLB files are important parts of the project. The TLB file is generated each time you compile your IDL file and the RGS file is generated when you add a component using the wizard.
You have these files in your project but you don't have to ship them with your DLL because they are integrated inside the DLL as a resource.
The RGS resource is used for component registering and the TLB is used for the interface information access.
I don't know why you decided to delete the TLB... But I recommend you NOT to do that.
Regards,
Alex Gorev,
Dundas Software.
|
|
|
|
|
when i drawed a couple of CEdit boxes on my little CControlbar, i lost my normal tab feature within the CControlbar , i guess it's understandable 'cause CControlbar has it's own taborders on the screen now, but is there an easy to keep this feature within the CControlBar or CDialogBar ?
thanks in advance!
|
|
|
|
|
Hello gurus,
How to implement scroll bars in an Explorer Bar? I have this explorer bar as a child window of IE which hosts browser control.
Any ideas??
regards
Mahesh
|
|
|
|
|
I'm confused; are you trying to scroll the browser control, or the contents of the explorer bar which holds a browser control and other things? The first is already implemented by the browser control, just let it do its job. The later requires you to create scollbar window objects and move them where you want and to create a window proc to handle the scrolling messages.
|
|
|
|
|
Hi Erik,
Ok, I have created an Explorer Bar. I have created a window using AxWindow on the top of an Explorer Bar. This AxWindow hosts web browser control ( using IWebBrowser2) and displays one html file. And when you click on links, it displays as in defaulr browser. So basically I have two browsers ( IEs) same time. One in default and other inside Exlorer Bar. I am not touching default broweser. I want to create scroll bars for Explorer bar so I can move document inside it. Is it possible using IHTMLWindow2 and IHTMLDocument2 interfaces?? I am using ATL. Or is there any other way?? I have IWebBrowser2 interface for Explorer bar's browser too.
thanks
|
|
|
|