|
Hi,
In MFC there is a global function "AfxGetMainWnd" which can retrieve the pointer to the main frame window. However in WTL I did not find anything like that. Does that mean I have to add the pointer manually?
Thanks for your attention.
Lei
|
|
|
|
|
No, there is no built-in main window accessor. You can just add a global CMainFrame* variable, or if you want to be OO, derive a class from CAppModule and add the variable there, with a WtlGetMainWnd() accessor.
--Mike--
"Big handwavy generalizations made from a position of deep ignorance is one of the biggest wastes of time on the net today.
-- Joel Spolsky
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
|
|
|
|
|
If i understand correctly you want to get handle of main frame window??If main frame window present activeX host container thus it support IOleWindow interface and throught one you can get acess to it handle.
Sorry for bad eanglish
|
|
|
|
|
Does WTL work with Windows CE?
|
|
|
|
|
|
Not only is it an old version of WTL, it is probably breaking copyright laws. Does this site have permission to redistribute WTL?
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
I ran across something interesting in VS.NET 2k3. I'm not sure if this is by design or not, so I thought I'd ask here to see if I'm the only one experiencing this issue:
I'm coding an Internet Explorer band control using ATL. I decided to take the plunge and use attributes rather than the traditional class heirarchy. I found that the RGS file is never parsed! Apparently the "module" attribute takes care of the AppID and the "coclass" attribute registers the COM object CLSID.
Here's my dilemma: I need to add some registry settings that enable IE to launch my band control. I have always done this by placing the appropriate code in the RGS file. Now, it appears that I will have to overload the module's "RegisterServer" function in order to accomplish the same thing. Is this true?
Thank you for any light that can be shed on this subject!
--
Paul
"I drank... WHAT?"
|
|
|
|
|
Hello - I need to do some HTML parsing in a service. Does anyone know if the WebBrowser control is safe for this, i.e. doesn't throw up any dialogs? I interested in the DOM methods for parsing the HTML structure out. Anyone have some alternate suggestions for doing this?
Thanks!
Nate
|
|
|
|
|
Don't use the WebBrowser control. It is an ActiveX control and doesn't like to be windowless. Use the MSHTML control, which the browser actually hosts for its HTML parsing and partial rendering. The WebBrowser control handles other display issues, events, and other services.
The MSHTML control is what does the majority of the work and doesn't require a window. It's also lighter and give you access to all the HTML-related things like IHTMLElement , IHTMLDocument2 , etc.
Reminiscent of my younger years...
10 LOAD "SCISSORS"
20 RUN
|
|
|
|
|
Hi ppl, I am new to ATL and trying to add a simple richedit control in a window. But i get "syntax error: missing ';' ..." everytime. Following is my source code.
CMainWindow.h
#ifndef CMainWindow_h
#define CMainWindow_h
#include "stdafx.h"
#include "CNoteEdit.h"
class CMainWindow : public CWindowImpl < CMainWindow >
{
public:
DECLARE_WND_CLASS_EX(TEXT("NoteMainWindowClass"), CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS, COLOR_BTNFACE)
private:
BEGIN_MSG_MAP(CMainWindow)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
MESSAGE_HANDLER(WM_CLOSE, OnClose)
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
END_MSG_MAP()
LRESULT OnCreate(UINT msg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnClose(UINT msg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnDestroy(UINT msg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
};
#endif
CNoteEdit.h
#ifndef CNoteEdit_h
#define CNoteEdit_h
#include "stdafx.h"
class CNoteEdit : public CWindowImpl < CNoteEdit >
{
public:
DECLARE_WND_SUPERCLASS(NULL, RICHEDIT_CLASS)
BEGIN_MSG_MAP(CNoteEdit)
END_MSG_MAP()
CNoteEdit();
virtual ~CNoteEdit();
};
#endif
main.cpp
#include "stdafx.h"
CComModule _Module;
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
_Module.Init(0, hInstance);
CMainWindow _MainWindow;
_MainWindow.Create(0, CWindow::rcDefault, "Note - ", WS_OVERLAPPEDWINDOW);
_MainWindow.ShowWindow(nShowCmd);
_MainWindow.UpdateWindow();
MSG msg;
while (::GetMessage(&msg,0,0,0) > 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
_Module.Term();
return msg.wParam;
}
In the CMainWindow.cpp, its just code for closing the window and in CNoteEdit.cpp, it has an empty constructor and destructor. Now, if i just remove the CNoteEdit _noteEdit; line from CMainWindow.h then everything is ok (but no richedit ). I know i have to create the CNoteEdit object inside my main window, but i have to get pass the error first ... i think. Plz help me find out the error! Thankx in advance.
-Tareq
|
|
|
|
|
You don't #include stdafx.h in a header file. That should be the first #include in every CPP file, that's it.
--Mike--
"I'm working really, really fast at the moment, so a 3 minute outage becomes, due to time dilation, a 5 minute outage."
-- Chris Maunder, relativistic system administrator
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
|
|
|
|
|
Hi,
I have a dialog that is invoked form a property sheet that has various controls (edit boxes, check boxes) in my dialog. I need to know if the user modified (touched) any of these. There are function handlers for all of the controls (thru the COMMAND_ID_HANDLER macro). I expcted these to be called only when the user changes something. But these functions are being invoked when the dialog shows up!! What is the problem?
Regards
HV
|
|
|
|
|
Do you put data in those controls (like defaults or previous values) when you show the dialog? That would cause a change. You'll just have to ignore those until the dialog is initialized and displayed. Besides, when you use COMMAND_ID_HANDLER , all messages sent to the control invoke your handler.
If all you want to do is watch for changes, try this:
COMMAND_HANDLER(IDC_MYCTL, EN_CHANGE, OnChange) ...or at least something like it. If you initialize the dialog with text in the controls, you'll still have to ignore it at such time (perhaps through a state variable), but once the dialog is shown, any change on that control would call your handler.
Also, different controls use different command messages for changes. TextBox uses EN_CHANGE while other controls will most likely use something different.
Reminiscent of my younger years...
10 LOAD "SCISSORS"
20 RUN
|
|
|
|
|
ok, go that. in fact, that was the problem. thanks a lot for your suggestion. really appreciate that.
|
|
|
|
|
|
Yes, but it depends on the template types of the list and the map. Map contains a pair, so if you want to directly copy the pair it's easy. I'm guessing that's not what you want though. Could be harder if you just want one of the elements of the pair.
#include <string><br />
#include <list><br />
#include <map><br />
#include <algorithm><br />
<br />
using namespace std;<br />
<br />
int main()<br />
{<br />
map<int,string> m;<br />
list<pair<int,string> > l;<br />
m[0] = "zero";<br />
m[1] = "one";<br />
m[2] = "two";<br />
m[3] = "three";<br />
std::copy(m.begin(),m.end(),std::back_inserter(l));<br />
<br />
return 0;<br />
}
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
If you're using an STL implementation with the select2nd SGI extension, then you can extract the values out of the pair easily (the following code example is for gcc):
#include <iostream>
#include <map>
#include <vector>
#include <ext/functional>
#include <algorithm>
using namespace std;
using namespace __gnu_cxx;
int main(int argc,char **argv) {
map<int,int> mint;
mint[0] = 1;
mint[1] = 2;
mint[2] = 3;
vector<int> vals = vector<int>(3);
transform(mint.begin(),mint.end(),vals.begin(),
select2nd<map<int,int>::value_type>());
for (vector<int>::const_iterator iter = vals.begin();
iter != vals.end(); ++iter)
{
cout << *iter << endl;
}
}
I can't check if select2nd is supported in VC's STL implementation right now, sorry
- Mike
|
|
|
|
|
Hello,
Sorry for my english, it's not good.
I Would Like to modify the CRect rcBound pass to OnDraw Function in ActiveX control development, for fix the size of my control in any container.
Help me please.
Thank you.
Guy
|
|
|
|
|
compiling some code with just a few ATL classes ( CAtlString and CAtlArray ), I am running into compiler errors. I am using ATL to avoid MFC, and am running into this converting some XML(CMarkup) code.
The errors are:
<font size="0"><br />
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlcoll.h(467) : error C2825: 'ETraits::INARGTYPE': cannot form a qualified name<br />
c:\Projects\XML\MarkupATL\Markup.h(130) : see reference to class template instantiation 'ATL::CAtlArray<E,ETraits>' being compiled<br />
with<br />
[<br />
E=CMarkup::ElemPos,<br />
ETraits=CMarkup::ElemPos &<br />
]<br />
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlcoll.h(467) : error C2039: 'INARGTYPE' : is not a member of 'operator``global namespace'''<br />
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlcoll.h(467) : error C2146: syntax error : missing ';' before identifier 'INARGTYPE'<br />
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlcoll.h(468) : error C2825: 'ETraits::OUTARGTYPE': cannot form a qualified name<br />
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlcoll.h(468) : error C2039: 'OUTARGTYPE' : is not a member of 'operator``global namespace'''<br />
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlcoll.h(468) : error C2146: syntax error : missing ';' before identifier 'OUTARGTYPE'<br />
</font>
What's going on here? What am I missing in terms of headers?
I include: atlbase.h, atlstr.h, atlcoll.h
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
I need to have a pair of std::string and int as key of the map. But doesn't seems to work. I am using Visual Studio 6.
Here is the test program i am trying
#pragma warning (disable:4786)
#include <iostream>
#include <string>
#include
#include <vector>
using namespace std;
#include <myclass.h>
void main()
{
map< pair<string, int="">, string> test;
CMyClass* c = new CMyClass();
// some useful processing ....
test.insert( pair< pair<string,int>,CMyClass*> > (("hello",35), c));
return;
}
Get folloowing error
error C2275: 'pair<struct std::pair<class="" std::basic_string<char,struct="" std::char_traits<char="">,class std::allocator<char> >,int>,class CMyClass *>' : illegal use of this type as an expression
When i change key from pair<string,int> to something non-pair, it works fine. Any idea? is it doable at all?
TIA
|
|
|
|
|
typedef std::pair<MyFirstType, MySecondType> TMyKey;
typedef std::map<TMyKey, std::string> TMyMap;
//you might need to provide comparison function as well
|
|
|
|
|
Thanks AlexO
Could you please give me a short example on how to define comparison operator
I am a newbie to STL stuff
|
|
|
|
|
The following is just an example, it really depends on what kind of pair you have. The main idea is that std::map uses "<" to sort the entries.
struct comparepairs
{
bool operator()(const TMyKey& left, const TMyKey& right) const
{
if(left.first < right.first)
return true;
else if(left.first == right.first)
return left.second < right.second;
else
return false;
}
};
typedef std::map<TMyKey, std::string, comparepairs> TMyMap;
|
|
|
|
|
Thanks again Alexo.
Still curious why the code i am trying is not working
map< pair<string, int="">, CMyClass*> test;
CMyClass* c;
test.insert( pair< pair<string,int>,CMyClass*> > (("hello",35), c));
is it some wrong syntax i am using?
|
|
|
|
|
pair is a template class, which means it is declared when used
Anonymous wrote:
test.insert( pair< pair,
second usage of pair is wrong because pair without template parameters does not make sense
|
|
|
|
|