|
I don't use the typedef thing at all, I think it's ridiculous, and there are better ways to obsfucate ones code, if you really want to.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I don't typedef my STL containers, I typically declare them as one might a variable; encapsulated in a class.
<br />
class MyIntClass<br />
{<br />
....<br />
<br />
private:<br />
list<int> intList;<br />
list<int>::const_iterator intListIterator;<br />
<br />
....<br />
<br />
};<br />
Maybe a better question is what is the advantage of one over the other, then apply that to your programming situation ...
:..::. Douglas H. Troy ::..
Fold with us|Development Blogging|viksoe.dk's site
|
|
|
|
|
Sorry -I posted this to C++ forum but it may be more appropriate here.
Hi,
I've trying to create a browser helper object (BHO) for explorer. I've got a main "manager" class that initializes two objects. Each of these uses an simple XML parser (using MSXML). Now, when parsing XML files, I want to store the results to a struct array (not a class). The struct array is in turn comprised of a few other struct arrays. All mem allocation is static, only the topmost parent struct array is dynamically allocated. That's where the problem is: When I allocate (using new) the struct arr in the first object, its ok. Then when I init the second obj, the new fails and crushes the explorer. I did a simple test in the second obj:
int *i = new int[x];
when x is <255 it's ok. if x>=255 then it crashes (and of course, my struct arr is bigger than 255*sizeof(int) bytes). I don't think I have any serious mem leaks in the code before this.
Has anyone seen this before? Is there a memory limit imposed by explorer (unlikely as it sounds)? I would appreciate any comments.
Thanks,
Pete
|
|
|
|
|
|
I thought that it would be like this. Still, I can't understand why I cannot exceed a limit when allocating memory (except if I have a really serious leak -but when IE is loading, memory consumption looks normal).
Thanks.
|
|
|
|
|
I ported my VS2003 PocketPC WTL project to VS2005 and I have the problems
with resources.
When I modify a Dialog in my resource editor I get an error
Error 1 error RC2104 : undefined keyword or key name: DS_FIXEDSYS
Any idea?
Thanks
|
|
|
|
|
|
Winuser.h reveals:
#if(WINVER >= 0x0400)
#define DS_FIXEDSYS 0x0008L
Good music: In my rosary[^]
|
|
|
|
|
|
Hi,
I have to store 10 strcture in vector.
struct
{
int
int
int
int
};
Can you please help me. I am new to stl programming.
Thanks
|
|
|
|
|
use the <pre> tag to format your post correctly, b'cause we can't see anything on your question.
moreover, what is exactly your request ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Vectors can hold pretty much anything with a name, so if you have your struct defined like:
struct myStructure {<br />
int one;<br />
int two;<br />
int three;<br />
int four;<br />
};
then just define a vector of myStructs like so:
vector<myStructure> myVector;<br />
myVector.push_back(firstStructure);
then you can just access your data like you would with a basic array, ie
myStructure temp;<br />
temp=myVector[5];
or you can modify in place like
myVector[5].one=37;
Pretty cool stuff.
|
|
|
|
|
Hi, all!
I'm writing scatter plot program and it, uses function SetWorldTransform() to map coordinate space of whatever data I send to it onto coordinate space of the screen. The function works well, but as well as transforming coordinate space, it transforms objcects(which I draw using GDI+) in it, and I don't need that.
Is there a way to bypass transformation of graphics objects by means of GDI+ or is there any other function that does just that?
|
|
|
|
|
Hi,
I want to use templates to select one of the overloaded functions, basically I am looking for something like this
template<int v>
struct Int2Type
{
enum { value = v };
};
void Function(Int2Type<0>)
{
cout << "Function with Int2Type<0> selected"; -------------- (1)
}
void Function(Int2Type<1>)
{
cout << "Function with Int2Type<0> selected"; -------------- (2)
}
int main()
{
int iselect = GetValue();
Function(Int2Type<iselect>()); // selects (1) if iselect = 1 else selects (2)
// if iselect = 2
return 0;
}
My question is, Whether it is possible to write such a code? Or can someone suggest how to achieve the desired functionality.
Thanks in advance
|
|
|
|
|
You cannot do that: the basic problem is that overload selection takes place at compile time, whereas your iselect value is only known at run time.
So, you need some kind of dynamic dispatch framework to achieve what you're after. The following is a possibility (lacking the terseness of function overloading):
typedef void (* function_t)();
void function0(){...}
void function1(){...}
function_t function[]={&function0,&function1,...};
int main()
{
int iselect=GetValue();
function[iselect]();
} Hope this helps.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
Hi,
I managed to implement some basic drag and drop support in my Tree Control by following the article: http://support.microsoft.com/default.aspx?scid=kb;en-us;214814 on the microsoft site.
However, I'd now like to implement automatic scrolling when the user moves the cursor to the top or end of the view. How would I go about doing this? Can anyone point me to some information?
Thanks in advance.
|
|
|
|
|
Hi guys, I wrote a ATL program (an addin) for MS Word using the article provided by Amit Dey on Outlook addins. It works fine. but the sink events only work for a single instance of Word. i want my application ( and the Sink Events) to function with multiple instances of Word. Can someone help me out? I'm not really sure what the problem is. My command bars are created on all instances of Word but nothing happens when i click them.
This how i implemented my sink event (just like Amit did it):
ATL_FUNC_INFO OnClickButtonInfo =
{CC_STDCALL,VT_EMPTY,2,{VT_DISPATCH,VT_BYREF | VT_BOOL}};
void __stdcall CAddin::OnClickButton(IDispatch*
/*Office::_CommandBarButton* */ Ctrl,
VARIANT_BOOL * CancelDefault)
{
USES_CONVERSION;
CComQIPtr<office::_commandbarbutton> pCommandBarButton(Ctrl);
//the button that raised the event. Do something with this...
MessageBox(NULL, "Clicked Button1", "OnClickButton", MB_OK);
}
Please help me with my difficulty.
Thanks
|
|
|
|
|
Hi,
I was wondering if anyone knows of a combined Tree and List view control for WTL?
The UI I want to create is a list view with three columns. The first column contains the Tree View items and the second and third columns contains properties of each tree item, which are displayed as check boxes.
Thanks in advance.
|
|
|
|
|
Here[^] you go. Although, it had repainting issues with WTL 7.1.
I can't remember the exact code for fix the repainting issue, and I don't have the source code readily available right now. But it's in the DrawItem() method. IIRC, the drawing of a tree item needs to be extended to the far right side of the client area. You'll notice the black areas created when opening tree nodes.
Other than that, I have not found any issues with the control.
Good music: In my rosary[^]
|
|
|
|
|
I was creating a COM+ class using ATL as the following. The name of the interface was called ISample. The COM+ class was named CSample.
Basically, it looks like that:
interface ISample: IUnknown{
...
}
class CSample: ISample{
...
}
After compiling, I configured CSample using component services manager.
Then, I created a very simple client to use CSample. It looked like that:
void main(){
CoInitialize(0);
{
CComPtr<isample> sample;
HRESULT hr = sample.CoCreateInstance(CLSID_CSample); // <--- I got problem here
...
}
CoUninitialize();
}
I got problem when trying to create the CSample COM+ object. I was told in hr "E_NOINTERFACE".
But if I made the ISample a dual interface, everything became OK.
My question is: Is it required that ISample must be dual or derived from IDispatch? If not, what is wrong with my program?
Thanks a lot!
|
|
|
|
|
I hope it will work.
ISamplePtr sample ;
sample.CoCreateInstance(CLSID_CSample);
bye
anjicafe
|
|
|
|
|
Hi,
I have a main window and a dialog. The dialog is meant to be a floating toolbar which appears when the main window loses focus or is minimized. When the child dialog gains focus, the title of the previously active window disappears. I use ::ShowWindow() and ::SetActiveWindow() to switch between the two.
However, if I move another window over the title bar of the inactive window the portion of the title covered will repaint itself.
Has anyone encountered this problem before? Is there a way I can force a window title to repaint itself?
Thanks in advance.
|
|
|
|
|
Suppose I want an application which takes a source file and outputs its data members and functions.
Supposed to develop into a kind of class view explorer.
Regarding parsing the source file ....
should i go for using regular expressions rules for this parsing or
should i go for a language representation in context free grammer[CFG] and use the CFG rules for parsing
or is there any other possible ideas for source file parsing
awaiting advice
fordge
|
|
|
|
|
CFG.
You could use Lex/Flex and Yacc/Bison ( ) or something like Antlr[^] ( ).
The Antlr site has several free for use grammars for different languages.
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
C++ code is hard to parse, unless you have an LL(k)-parser, IIRC. I believe ANTLR is a generalized LL(k) parser generator. But I'm unsure if there are any freely available LL(k) grammars for ISO/IEC 14882 C++.
Many class viewers do heuristic parsing, which are basically "creatively guessing" parsers. I don't think they are strict CFG parsers.
Good music: In my rosary[^]
|
|
|
|