|
I am not firing the event manually.. i am using the code generated by the ATL Wizard as such..
For firing event from worker thread .... microsoft has given link to be implemented for the same thats the only change i have done and rest of the code i have not touched...
with regards
Abhiraj
modified on Wednesday, May 7, 2008 12:27 AM
|
|
|
|
|
Hi all!
I would like to serialize/deserialize a std::vector of objects of a class into some buffer of a stream or of some other buffer. Can you address me about how to do this with the highest performance possible?
If I had an ARRAY of these instances..I would switch to a std::vector using this code:
CMyClass d[20];
// fill the array!
std::vector<CMyClass> v(d,d+sizof(d)/(d[0]));
What in case I use deserialization from a stream?
Is there a way to let the std::vector copy or use itself access the buffer
of a stream?
I would like to avoid the istream::read line below to go faster..do you know some way or address some nice super STL feature?
CMyClass d[20]; // buffer is created continuosly
istream::read( d, 20 ); // copy data from the buffer ( IS AVOIDABLE? )
std::vector<CMyClass> v( d,d+sizof(d)/(d[0])); // get the std::vector
Kind Regards
ManuStone
|
|
|
|
|
Assuming CMyClass has a std::istream extractor, you could use this to read from a file called "a.a"
std::ifstream is("a.a");
std::vector<CMyClass> v;
std::copy(std::istream_iterator<CMyClass>(is), std::istream_iterator<CMyClass>(), std::back_inserter(v));
|
|
|
|
|
Thank you Stuart
I will test it immediately!
Actually what I would like to achieve is to directly move an entire block of data from the stream to vector someway!
I have doubt that std::copy probably might be slow, but I have to test it before saying that
Have a nice evening!
ManuStone
|
|
|
|
|
I am working on a button that has a custom shape, and I wanted to give the user the option to match the button color scheme used by XP. I was planning to fill the button region with a gradient matching the current XP theme.
I asked this question on the Yahoo WTL forum. The answer makes writing a custom shaped button a little more difficult.
I am trying to use theme colors in XP to draw a gradient background
that is not rectangular. I am utilizing atltheme.h to call
GetThemeColor(BP_PUSHBUTTON, PBS_HOT, TMT_GRADIENTCOLOR1, &c). I am
trying to retrieve just one gradient color at the moment. I've tried
using DrawThemeBackground for a button. The colors are correct, but
the shape cannot be changed to fit the region I am filling.
I've discovered that most theme parts do not return gradient colors.
(I am able to get some colors, just not the gradient colors.) Does
anyone know how to retrieve the gradient colors used to draw themed
buttons? Most of the examples I have found hard code the gradient
colors to look like the theme colors.
The answer I received:
Themed buttons are actually drawn using a template bitmap, so there are no
gradient colours to retrieve.
Is this documented some place? I searched using google and I've had no luck locating any references to bitmap templates used for buttons.
|
|
|
|
|
Jim Barry answered all of my questions on Yahoo WTL[^]. Many thanks to him.
Short answer: Oh yes, totally undocumented.
Jim's answer also made it clear to me why custom shapes are difficult to theme if you want to use the "Button" theme.
I am most grateful for Jim's quick and accurate answers.
|
|
|
|
|
Hello friends,
How can I use the VB.NET's library in VC++.
Any article that will give the clear idean on this problem.
Thanks in advance to all of you.
ritz1234
|
|
|
|
|
You could either try using COM interop[^], or you could check out how to use the /clr switch[^] with the C++ compiler.
--
Kein Mitleid Für Die Mehrheit
|
|
|
|
|
I developed a desktop application with WTL, which contains a toolbar. The tool bar was ceated like as following codes. It works well. But when I tried to modify the style of the toolbar and make it to be docable or vertical. I failed in all attempts. I wonder why it becaoms so difficult with WTL while it's very easy with MFC to modofy a toolbar from horozontal to vertical dynamically. I tried to look for useful sample codes from internet. But, failed to find any matching samples. I believe it's a simplist requirement for a toolbar to be docable or to present in vertical direction. There must be many developers who ever encountered the same confusion as me. Then how do they resolve thire problems?
Can anyone provide me some hints or contribute some of his samplke codes. I'll apprieciate so much. I attahched my sample. Can anyone help me to modify the toolbar into vertical or docable one? Thanks a lot in advance.
BOOL CreateToolBarCtlr(HWND hParent, CToolBarCtrl& toolBarCtrl, RECT rcBar, LPCTSTR lpszCaption) { ATLASSERT( hParent && lpszCaption); if(hParent == NULL || lpszCaption == NULL) return FALSE; <br />
ATLASSERT(toolBarCtrl.m_hWnd == NULL); <br />
if( toolBarCtrl.m_hWnd != NULL) return FALSE; <br />
DWORD dwStyle = CCS_NODIVIDER | CCS_NOPARENTALIGN | CCS_NORESIZE;<br />
dwStyle |= TBSTYLE_TRANSPARENT | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS |<br />
TBSTYLE_CUSTOMERASE; dwStyle |= ATN_CHILD_STYLE; <br />
toolBarCtrl.Create(hParent, rcBar, lpszCaption, dwStyle, 0); <br />
ATLASSERT(toolBarCtrl.IsWindow()); <br />
DWORD dwStyleEx = toolBarCtrl.GetExtendedStyle(); <br />
dwStyleEx |= TBSTYLE_EX_DRAWDDARROWS; <br />
toolBarCtrl.SetExtendedStyle(dwStyleEx); <br />
toolBarCtrl.SetButtonStructSize();<br />
toolBarCtrl.SetImageList(m_hImageList); return TRUE; }.
|
|
|
|
|
Hi, everyone
It's really urgent for me to learn more about how to create a vertical or docable toolbar with wtl. I'll apprieciate you so much if you give me any advice, even if give me any WTL forum URL, where I may found answers or solutions to my question.
Thanks a lot in advance.
|
|
|
|
|
HWND hWndToolBar = CreateSimpleToolBarCtrl(m_hWnd, IDR_MAINFRAME, FALSE, ATL_SIMPLE_TOOLBAR_PANE_STYLE| CCS_VERT | TBSTYLE_WRAPABLE );
That should get you a vertical toolbar. Or try viksoe.dk ( look for atldock or WTL Docked UI )or even here[^] on CodeProject.
|
|
|
|
|
Hi,
Charles, Thanks a lot for your reply. I tried according to your hint. But didn't get vertical toolbar. And I don't know what's wrong happened.
Can you contribute a sample WTL project which demonstrates the vertical tooblar implementaion.
You may also send it to me by Email to JackLin5168@gmail.com or JackLin5168@yahoo.com .
Thank you so much. Charles.
Jack. China
modified on Monday, May 5, 2008 3:27 AM
|
|
|
|
|
Can anyone help me to resole this problem? I think there must be solution to my question.
|
|
|
|
|
Did you ever solve this problem? I am interested in the solution as well
|
|
|
|
|
Hello,
I have the following code that searches a list of wchar_t * strings.
What I want is a function like this:
vector <wchar_t *="">paths;
find (paths.begin(), paths.end(), L"some string");
What do I need to do to get this to return the string I'm searching for?
- BRC
|
|
|
|
|
This will not return a string but an iterator to the matching string. Your code would look something like this.
bool Comparer : public std::binary_function<wchar_t*, wchar_t*,bool>
{
public:
bool operator()(const wchar_t* s1, const wchar_t* s2) const
{
return (wcscmp(s1, s2) == 0);
}
};
std::vector<wchar_t*> paths;
std::vector<wchar_t*>::const_iterator it;
it = std::find_if(paths.begin(), paths.end(), std::bind2nd(Comparer(), L"some string"));
if (it != paths.end())
{
...
Pax Domini sit semper vobiscum
|
|
|
|
|
Hi,
I am having an issue compiling the ATL/Com dll;
I have Three classes and their interfaces in a com dll as:
1- IMailInterface
2- IMyInterface1
3- IMyInterface2
Now,MFC application uses these interfaces. My application will never directly deal with 2nd and 3rd interface. Everything will be done with the help of IMainInterface. I want to add a method to IMainInterace as
GetMyInterface1(IMyInterface1** ptr); which will retrun the IMyInterface1 pointer
But while comiling getting an error error as:
D:\Work_ganesh\MPlusSrvOpticalDevice\Work In Progress\Ganesh\Samples\DemoCOM\DemoCOM.idl(18):error MIDL2025 : syntax error : expecting a type specification near "IMyInterface1"
D:\Work_ganesh\MPlusSrvOpticalDevice\Work In Progress\Ganesh\Samples\DemoCOM\DemoCOM.idl(18) : error MIDL2026 : cannot recover from earlier syntax errors; aborting compilation
Error executing midl.exe.
I tried adding header file but it didn’t worked.
Thanks.
"A winner is not one who never fails...but the one who never quits"
|
|
|
|
|
Ganesh_T wrote: But while comiling getting an error error as:
D:\Work_ganesh\MPlusSrvOpticalDevice\Work In Progress\Ganesh\Samples\DemoCOM\DemoCOM.idl(18):error MIDL2025 : syntax error : expecting a type specification near "IMyInterface1"
D:\Work_ganesh\MPlusSrvOpticalDevice\Work In Progress\Ganesh\Samples\DemoCOM\DemoCOM.idl(18) : error MIDL2026 : cannot recover from earlier syntax errors; aborting compilation
Error executing midl.exe.
Could you post the actual idl code? That would tell me much more about what went wrong.
Nathan
|
|
|
|
|
Hi,
Can any one give me the details about CoCreateInstanceAsAdmin API.
Thanks & Regards
...swamy
|
|
|
|
|
I thought this[^] explained it pretty well.
--
Kein Mitleid Für Die Mehrheit
|
|
|
|
|
hi All,
My VB Client using ATL COM works fine while running under Debug mode but in the release mode it gets crashed as ATL COM tries to fire event to the VB Client
Here are the Details of what i have developed as ATL COM in C+
I have developed a simple ATL COM in C++ , This ATL Com has a dependency which is a DLL , this DLL sends a notification to the ATL COM by using a registering a function of a ATL as callback , i have used a static function of ATL Object as callback function as we cannot give member function of the class as callback function due to "this" pointer.
Now Dll sends notification to this static function of ATL COM and this ATL COM send the notification further to the COM Client by firing event.
Important to note , since notification is received by static function of ATL class , so i had to use global pointer to the ATL COM in that static function to Fire_Event , as soon as global pointer fires events VB client in release mode gets crashed
Here is the code snippet
CTest_ATL *g_pTestATL; // Glboal Pointer
STDMETHODIMP CTest_ATL::funSubscribe(void)
{
g_pTestATL = this;
m_hDLL = LoadLibrary(TEXT("\\DLL_PlaceCall.dll"));
if(NULL == m_hDLL)
{
return S_FALSE;
}
return S_OK;
}
// This is a callback "static" function which gets registered to the DLL
// As this static callback function gets called i am firing event using
// global pointer to ATL_COM as shown below
int CTest_ATL::EventCallBack()
{
g_CallMonitor->Fire_IncomingCall(CComBSTR("This is a COM Message"));
return S_OK;
}
Any pointers in this issue will be a great help.....
with regards
Abhiraj
|
|
|
|
|
garammasala wrote: My VB Client using ATL COM works fine while running under Debug mode but in the release mode it gets crashed as ATL COM tries to fire event to the VB Client
Do you have any code you depend on inside an ATLASSERT statement? These are removed in release builds. Another possibility is that the optomizer is breaking something. You may want to create a release build with debug information so that you can step through the code the compiler is actually generating for the release build.
Also, unrelated to your problem, it looks to me like g_pTestATL and g_CallMonitor could be static member variables of CTest_ATL.
Nathan
|
|
|
|
|
Hi Nathan
< Also, unrelated to your problem, it looks to me like g_pTestATL and g_CallMonitor could be static member variables of CTest_ATL >
I made a mistake while giving the question i.e "g_CallMonitor" is nothing it is the global pointer "g_pTestATL" which is firing the event from the static function.... replace g_CallMonitor with g_pTestATL
I have found the solution to the problem but was not really able to understand the whole solution , Below is the link
http://vcfaq.mvps.org/com/1.htm
May be you can through some light....
|
|
|
|
|
garammasala wrote: I made a mistake while giving the question i.e "g_CallMonitor" is nothing it is the global pointer "g_pTestATL" which is firing the event from the static function.... replace g_CallMonitor with g_pTestATL
That makes perfect sense.
garammasala wrote: I have found the solution to the problem but was not really able to understand the whole solution , Below is the link
http://vcfaq.mvps.org/com/1.htm[^]
May be you can through some light....
I'm not sure what you don't understand. I assume that you've implemented one of the options and had it work, because otherwise you wouldn't know for sure it was a solution. I've used both the hidden window and the GIT solution, so I may be able to answer any more specific questions you might have about them. In general, using multiple threads well will require lots of studying and lots of practice. There are probably articles on CodeProject that can tell you a lot about it.
Nathan
|
|
|
|
|
yes Nathan
Your are right that i have implemented one of the options and my work was done...
Since ATL COM is very vast so no idea where to start exactly to find the solution for the same ,also the solution given in the link which i gave requires a lot of deep understanding of ATL before the solution provided can be understood, As you have said there are so many articles in the Code project that can tell me a lot better about ATL and basically the solution given in the links...
so will request to point some of those if you can... ?
with regards
Abhiraj
modified on Monday, April 28, 2008 1:38 PM
|
|
|
|