|
Hi,
I'm a C++ programmer, and i need to know what is partial specialisation. Whats its significance with VC++ (like whether VC supports this feature, if not why there is a need for vc to have this feature). Any other C++ (or language) implementations support this.
Thanks in advance.
Kannan
|
|
|
|
|
Template Specialization can be thought of as Template overloading. You can declare a template, and then specialize the templates for specific cases (much like overloading a function allows you to specify what code gets called for different arguments).
There are two types of specialization, Explicit specialization and Partial Specialzation.
Explicit specialization is when you specialize all template parameters. For instance:
template<class t=""> class blah;
template<> class blah<char>;
The second line is an explicit specialization. If you create a template with a char type then it uses the code in the second declaration.
Partial Template Specialization is when you do not specialize all arugments. For instance:
template<class t1,="" class="" t2,="" int="" i=""> class A;
template<class t1,="" class="" t2,="" int="" i=""> class A<t1, t2*,="" i="">;
In this example, the second declartion is a partial template specialization because it only specializes the second parameter (by making it a T2 pointer instead of a T2). You can also partial specialize a template with different parameters, such as:
template<class t1,="" class="" t2,="" int="" i=""> class A;
template<class t,="" int="" i=""> class A<t, t*,="" i="">;
In this case, you are specifying only 2 parameters for the specialization, but using the first argument again as a pointer in the second.
VC++ does not support PTS, and it will not support it in VC7 either (sadly).
|
|
|
|
|
Doh! HTML strikes again. Don't be confused, some of Erik's stuff between angle-brackets doesn't get rendered. View the source to see them. Just thought I'd let you know.
(Have to admit, I stared at the examples thinking "huh" for a while myself, hehehe.)
|
|
|
|
|
Ooops... I need to fix this... I'm not sure how. How does one escape out <'s in HTML?
|
|
|
|
|
To put literal "<" and ">" characters in HTML (or XML), you type "<" and ">", respectively. To type a literal "&" character, you must type "&".
|
|
|
|
|
Template Specialization can be thought of as Template overloading. You can declare a template, and then specialize the templates for specific cases (much like overloading a function allows you to specify what code gets called for different arguments).
There are two types of specialization, Explicit specialization and Partial Specialzation.
Explicit specialization is when you specialize all template parameters. For instance:
template<class T> class blah;
template<> class blah<char>;
The second line is an explicit specialization. If you create a template with a char type then it uses the code in the second declaration.
Partial Template Specialization is when you do not specialize all arugments. For instance:
template<class T1, class T2, int I> class A;
template<class T1, class T2, int I> class A<T1, T2*, I>;
In this example, the second declartion is a partial template specialization because it only specializes the second parameter (by making it a T2 pointer instead of a T2). You can also partial specialize a template with different parameters, such as:
template<class T1, class T2, int I> class A;
template<class T, int I> class A<T, T*, I>;
In this case, you are specifying only 2 parameters for the specialization, but using the first argument again as a pointer in the second.
VC++ does not support PTS, and it will not support it in VC7 either (sadly).
|
|
|
|
|
G'day,
I'm thinking of porting one of our apps from DAO to ODBC for database access. I understand the correlation between CDaoDatabase/CDatabase and CDaoRecordset/CRecordset, but was wondering if there are any ODBC equivalents to the DAO CDaoTableDef and related classes?
When opening a database, my apps always check that the database's schema is complete and up to date. The apps create any new tables/fields that are required before proceeding.
I'd like to be able to do the same thing with the ODBC version, but the only obvious solution I see is sending raw SQL to the data source via the ODBC API. This is OK, but I was wondering if any of you ODBC gurus out there have a more elegant solution.
Actually, in an ideal world, I'd like my apps to support both DAO (speedy single-user performance) and ODBC (multi-user client/server), but I guess that's too much to hope for.
Any advice would be appreciated.
TIA
Steve
|
|
|
|
|
Hi,
Use ATL's OLE DB Provider, Consumer Templates. This will satisfy all yr requirements. Or use OLEDB
MFC class instead. These stuffs r esay to use and also gives fast and reliable services than that of other
MFC stuffs.
|
|
|
|
|
Thanks for that Mathan.
I was browsing the MSDN help & MS web sites last night and ended up printing off a zillion topics on DB access. I'm just puring my way through the pros and cons of the various options today. I'll check out the OLEDB stuff later.
Thanks again,
Steve
--------------------------------------
Steve Driessens
|
|
|
|
|
I am trying to create a webbased text editor using MFC ActiveX.
To do this, I created an MFC activeX file with all the default options.
Then, I created a new class using the Wizard, which subclasses RichEditCtrl.
I included the header file of this class to my main ActiveX file(i.e. xxxCtl.h
file ) , created a member variable for the RichEditCtrl class inside my xxxCtl.h
file and then, used its Create method, to create an instance of it within
my ActiveX's OnCreate method.
i.e.
in my header, I got
CRichEditor x;
in my ActiveX cpp, I got
CMainCtrl::OnCreate()
{
...
x.Create(.......);
}
That's all fine as I get one big honking Edit box.
But now, I want to add menus and stuff and can't figure out a way to do that.
Anyone out there would know about this? Typically, menus are part of the
CMainFrame, but since this is an AcitveX and has no frame, I am not sure
where I could create it!
I would really appreciate the feedback!
thanks
|
|
|
|
|
You create the menus in the handler for WM_CONTEXTMENU or WM_RBUTTONDOWN.
|
|
|
|
|
Hi there and thanks for the response!
I actually meant menus for toolbars...
I want to add a toolbar and then add menus to it, but I am not sure how, since that kind of thing is usually done at a FrameWnd level and MFC ActiveXs don't have any Frames as far as I know!
|
|
|
|
|
Help me somebody. Please.
When I start using function from the NetBIOS interface like UCHAR ret=Netbios(PNCB pncb);
my linker send me error LNK2001: unresolved external symbol _Netbios@4.
I connect "Nb30.h" file.
What the problem? The samples from MSDN also want not link.
If you can help, please help me solve this problem.
|
|
|
|
|
The header file means you can compile, but you need to include the .lib file in your Object/Library modules ( under 'Link' in project properties)
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
Big Thanks.
It's very easy, after learn it.
|
|
|
|
|
Please see the zip file at:
www.freebox.com/g8rpal/cfinal.zip
I am having problems completing this assignment and any help would be greatly appreciated...
All files are in the zip.
Thanks!
|
|
|
|
|
Dear All !
We are trying to use the Stingray Object Edit MFC Control
(SECEditCtrl)as a child window and a CWindowImpl derived class as its parent.
All is working except the cursor keys and the enter, backspace and delete keys do nothing. But we can type in text and selecting with the mouse and setting the caret with the mouse is working.
Any ideas on how to use a MFC CWnd inside a ATL/WTL CWindowImpl class.
Kind regards,
Alex Klinsky
ATAIR Software, Austria
|
|
|
|
|
I'm working on a small utility that I want to be able to update itself via int internet (via FTP). The user will select a drop-down menu item "Check for update". At startup, if possible, a couple different files are already pulled down from the FTP server I'm using so pulling down an updated EXE should be easy enough. In fact, I already implemented all of that including the version checking... everything except how to actually replace/relaunch the EXE. What is the best way to go about doing this?
|
|
|
|
|
Here is a way that occurs to me:
Write a second application to do the update, let's call it "update.exe" and your utility program "utility.exe".
When your utility gets an update:
1)it saves the new version of itself using a temporary filename
2) it creates a named mutex
3) it starts update.exe which blocks on this mutex.
4) the utility terminates, releasing the named mutex right before it dies.
The running update application senses that the mutex has been released and then deletes the old "utility.exe" and renames the temporary file to "utility.exe".
If your utility needs to save state between incarnations then it can do so using an ini file or registry entries.
|
|
|
|
|
That sounds pretty good and wouldn't be very difficult at all to implement. However, the utility is pretty small and my goal is to keep it as simple as possible for distribution.
It's purpose is to keep a device of ours updated by querying for current version information, checking the FTP server for the latest updates, bringing them down, and putting the updates on the device. All this works fine. However, I ALSO want the utility to update itself if/when the need arrives.
Our customer base isn't exactly technically savy at times so the goal is to make this as simple as possible. Therefore, I'd like to work out some way to do this all in one EXE.
In UNIX I remember there was a way to rename the executable at runtime. Is there a way to do this with an MFC app? Then I could rename the running app, download the new version, shut down the renamed app and launch the new one. Is that possible?
|
|
|
|
|
>>>In UNIX I remember there was a way to rename the
>>>executable at runtime. Is there a way to do this with an
>>>>MFC app? Then I could rename the running app, download >>>the new version, shut down the renamed app and launch >>>the new one. Is that possible?
I don't believe you can, Please disprove me.
Ok here is another easy method
run OldApp,
When OldApp runs it checks a reg value to see if NewAPP exists,
if NewApp exists
{ OldApp executes NewApp
OldApp dies
} /// This leaves only NewApp running
else {OldApp Continues}
The only disadvantages with this are minimal,
You have two exe's instead of one installed !
Regardz
Colin Davies
|
|
|
|
|
I've done this before.
What I did was to download new.exe to a temporary folder named something like temp.exe then run it as such:
temp.exe -replace c:\path\to\current.exe
then immediatly exit current.exe
temp.exe should read the command line and set a timer for like 5 seconds (make sure we give current.exe enough time to exit) the timer will delete current.exe, copy its self over current.exe, and then run it as such:
c:\path\to\current.exe -delete c:\path\to\temp.exe
current.exe will then be your updated exe and should delete the temporary file.
Hope this helps
-zack
|
|
|
|
|
There's a bug in Windows ListCtrl, (Report mode), using GRIDLINES.
When scrolling from right to left slowly, vertical lines are not drawn.
This happens because (aparentrly) the control draws the vertical lines whem drawing the subitems which are on the right of the line. When scrolling from right to left, there will be a moment when left subitems appears completely visible on the screen, but the left line wont be visible. If we scroll again to the left, this line wont be drawn (BUG) because these subitem don't require to be redrawn.
I Fix this bug by invalidating the rectangle where the left line should be when scrolling.
Is there a FIX to the ComCtl32.dll?
|
|
|
|
|
What's the difference between using CWnd::SubclassDlgItem and use DDX_Control? I've noticed that ClassWizard uses DDX_Control.
|
|
|
|
|
I have created a Tree Control using ActiveX, and have done my own drawing by overriding the CTreeCtrl::OnPaint. However, when I try to draw icons using the CDC::DrawIcon function, my icons always appears at 32x32.
I have created an icon resource which is 16x16, loaded it into a HICON variable using ::LoadImage in an overridden CTreeCtrl::PreCreateWindow function, and in my overridden CTreeCtrl::OnPaint called the function
memDC.DrawIcon( point, m_hIcon )
where memDC is a CDC object, point is a CPoint and m_hIcon is my HICON variable.
What appears is the correct icon, but it has been stretched horizontally and vertically by a factor of 2. How do I prevent this so my output icon is 16x16 ????
Thanks
Ant
|
|
|
|
|