|
Hi Igor, thank you for answering.
I got exactly this code in my project (but the Variable names).
But it does not work. Scrolling via the mouseweel works fine, but there is no reaction when clicking the up/down buttons of the scroll bar. Neither when I'm trying to drag the scroll bar marker up or down.
Can I use a scrollbar here, that is going to be subclassed? I need a entire control, that can have a vertical and a horizontal scrollbar. Showing or hiding the scrollbars im managed by CScrollContainerImpl<>.
My class declaration looks something like that:
<br />
class CtrlPanel : public CScrollContainerImpl< CtrlPanel ><br />
{<br />
public:<br />
DECLARE_WND_CLASS( _T("CtrlPanel") )<br />
<br />
BEGIN_MSG_MAP_EX( CtrlPanel ) <br />
MSG_WM_ERASEBKGND( OnEraseBkgnd )<br />
CHAIN_MSG_MAP( CScrollContainerImpl< CtrlPanel > ) END_MSG_MAP()<br />
<br />
public:<br />
CtrlPanel( void );<br />
virtual ~CtrlPanel( void );<br />
<br />
HWND Create( HWND i_hParent );<br />
<br />
void UpdateLayout( void );<br />
void DoPaint( CDCHandle i_DCHandle ) {};<br />
<br />
private:<br />
LRESULT OnEraseBkgnd( HDC i_hDC );<br />
};<br />
This class later creates controls that are placed on it.
in UpdateLayout() I compute the size and position of each control, than i set the scrollsize...:
<br />
<br />
SetScrollSize( std::max( 1, ScrollSizeX ), std::max( 1, ScrollSizeY ) );<br />
Still, what am I doing wrong
|
|
|
|
|
Just a thought - maybe you need to handle all events yourself. Check codeproject articles on this subject (even MFC), see how what approach is used there. Sorry, can't give you more help.
Good luck.
|
|
|
|
|
Here I got an other approach to the question.
"How do I correctly subclass a CScrollContainerImpl?"
I guess a huge amount of developers has done this, but I simply cant gat it to work right. Still the scrollbars of static refuse to work.
So, if you managed to it - tell me how, please .
What contol do you put on your dialog to be subclassed?
Do you take care for any WMessgas, but those handled by CScrollContainerImpl<>?
|
|
|
|
|
Hello everyone,
Im new to the world of ATL and COM and am trying to create a wrapper class for a eVC++ library. I had the library working fine in a simple MFC app I wrote but the Linker fails in an ATL COM project I've created. Following is the error I receive.
wrapper.obj : error LNK2019: unresolved external symbol __imp__Read referenced in function "public: virtual long __cdecl CReader::InitReader(void)" (?InitReader@CReader@@UAAJXZ)
I'm guessing this error is due to a mis-understanding (on my part) of how ATL and COM link in external libraries. I was able to force the same error message in my MFC app by removing the .lib in "Project->Settings->Link:Object/Library Modules" which tells me that the Linker isnt seeing the library for some reason.
Any help is much appreciated!!
Thanks,
Ryan Bradley
|
|
|
|
|
Did you __declspec(dllexport) your class from your DLL, and __declspec(dllimport) from the DLL client?
Good music: In my rosary[^]
|
|
|
|
|
The library was provided to me by a vendor. Using "dumpbin.exe /exports" I can see the calls I need to make. I'm using the same .H file to __declspec(dllimport) in my ATL/COM project as with the MFC project that works.
That is what is confusing me. I'd guessed there is something different about how an ATL/COM project would attempt to link. This has to be something elementary that Im just missing.
Ryan Bradley
|
|
|
|
|
Now this is interesting...
The symbols the linker errors out on are slightly different between the ATL/COM and the MFC app. The ATL/COM object is looking for __imp__Read while the MFC app is looking for __imp_Read.
I can open up the .lib file in notepad and see __imp_Read. Any ideas??
Ryan Bradley
-- modified at 18:07 Friday 9th September, 2005
|
|
|
|
|
Hmm.. I think I know what it could be. IIRC, __cdecl functions are always given an _ prefix, while __stdcall aren't. Try with __cdecl or __stdcall (I'm too tired to sort out which one you need right now.. )
Good music: In my rosary[^]
-- modified at 18:15 Friday 9th September, 2005
|
|
|
|
|
Thanks for mentioning that. I think it is a piece of the puzzle. __cdecl decorates names while __stdcall does not. I've added #error directives to my header to ensure that __stdcall is used and it is. I've tried using __cdecl and it simply gives additional errors.
My header prototypes "__declspec(dllimport) int __stdcall Read()"
Despite all this sanity checking the linker is still looking for __imp__Read and not __imp_Read as it should.
Ryan Bradley
|
|
|
|
|
Man, I'm suffering with you. Linking errors are not fun.
Good music: In my rosary[^]
|
|
|
|
|
Hi
I have a WTL dialog box which is a layered window. I have used the following code
::SetWindowLong(m_hWnd, GWL_EXSTYLE, ::GetWindowLong(m_hWnd, GWL_EXSTYLE) | WS_EX_LAYERED);
g_pSetLayeredWindowAttributes(m_hWnd, 0, bAlpha, LWA_ALPHA);
where g_pSetLayeredWindowAttributes = (lpfnSetLayeredWindowAttributes)
GetProcAddress(hUser32, "SetLayeredWindowAttributes");
It works fine. I have another dialog dlg1, which I am going to display on some events in the main window.There is a combobox in the dlg1. when I click on combobox,portion of the combobox becomes transparent. It works fine with all other controls in dlg. Any idea?
Regards
|
|
|
|
|
I create an activex control(composite control) with ATL. Now I want to change the static's text color in the dialogbox.I do it like this:
HDC hdc = ::GetDC(GetDlgItem(IDC_STATIC_STATUS));
SetTextColor(hdc, 0x000000ff);
These two sentences are in the OnInitDialog function, but after this the color don't change.
Who can tell me why? And what shoud I do to change the color?Thanks.
|
|
|
|
|
You need to handle the WM_CTLCOLORSTATIC message in the dialog. That message will give you the HDC being used to draw the static control. Just set the text color on that DC, and you will achieve what you want.
For more info, see the MSDN docs.
Good music: In my rosary[^]
|
|
|
|
|
Jörgen Sigvardsson,thanks very much, I have successfully set the text color and I found that I should put MESSAGE_HANDLER(WM_CTLCOLORSTATIC, OnCtlColorStatic) before CHAIN_MSG_MAP, if not, it didn't work
|
|
|
|
|
Another question, there is a sentence in the MSDN:
"The system does not automatically destroy the returned brush. It is the application's responsibility to destroy the brush when it is no longer needed.
"
I wonder when I should destroy the brush and where did I get the brush's handle?
-- modified at 6:22 Tuesday 6th September, 2005
|
|
|
|
|
its about the brushes which u have created, for those ones u must have hadles to them
|
|
|
|
|
Hi,
I'm trying to make an activex plugin for IE. It will be used for displaying images that are coming in over the network.
To that end, I started off by making an ATL control that creates a thread which simply updates a text buffer with the current time, calls FireViewChange(), and sleeps for around one second.
This works in the test container, but not in IE. I've gathered that I can't call FireViewChange() from a "worker thread", but i'm getting confused quickly trying to find a workaround for that.
All of the stuff I find seems to be a few years old, and things are different, so I can't quite follow some of the tutorials of how to handle something like this.
Can someone give me a quick walkthrough of this?
Thanks,
--buddy
|
|
|
|
|
ActiveX controls are normally apartment-threaded (since they usually have UI), so you'll need to marshal the interface to the thread so it can use that to call FireViewChange() . I usually use the GIT (see CComGITPtr in ATL7) for this task, but if it's a one-time deal, you can also use CoMarshalInterThreadInterfaceInStream() .
--Mike--
Visual C++ MVP
LINKS~! Ericahist | 1ClickPicGrabber | NEW~! CP SearchBar v3.0 | C++ Forum FAQ
Pinky, are you pondering what I'm pondering?
I think so Brain, but if we shaved our heads, we'd look like weasels!
|
|
|
|
|
Hi Mike,
I've read something similar to that before, but I'm not a win32 programmer at all, so it goes straight over my head. Can you give me a code example?
I also thought of doing a windowed activex control, and then just painting to the HWND whenever I have a new image to display, thus bypassing the need to ask the container to redraw the control.
Will that work? Is there a better way? I really don't know if I'm approaching this right or not.
What I need is an ATL control that can be used in a web page, which continuously downloads and displays a JPEG from a remote host. Any suggestions of the best way to do that are greatly appreciated
Thanks again,
--buddy
|
|
|
|
|
I've noticed in examples of CoMarshalInterThreadInterfaceInStream() there are usually a vector of interfaces. Is this all subscribers to the event or am I stupid.
|
|
|
|
|
Not sure where you saw vectors used with CoMarshalInterThreadInterfaceInStream() , it only deals with one interface at a time.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | 1ClickPicGrabber | NEW~! CP SearchBar v3.0 | C++ Forum FAQ
"Linux is good. It can do no wrong. It is open source so must be right. It has penguins. I want to eat your brain."
-- Paul Watson, Linux Zombie
|
|
|
|
|
I am trying to create the Atl servce in VC++ for file monitoring. I am following the link "<http: www.codeproject.com="" atl="" atl_control_with_mfc.asp".="" i="" am="" using="" this="" sample="" code="" in="" sevice.
=""
but="" facing="" problem="" "ccomobject<cfilemonitorsink=""> *m_FileMonitorSink;. It is not including the CComObject"
It's not getting included properly.
|
|
|
|
|
I created a project using 'ATL COM AppWizard'.
After Selecting projecting Name from 'class view', I did not find the 'New ATL Object' Menu item either from Insert Menu or from Popup menu.
Could you please let me know by selecting/changing which options I can get this menu item.
|
|
|
|
|
You should reinstall your VS.
|
|
|
|
|
yes,otherwise there is no reason why it is not showing.
|
|
|
|