|
Hi all
I get a some complcation here:
template <class t=""> void fun(..)
{
...
switch (typeid(T))
{
case (typeid(char)):
....
break;
}
...
}
/*
This snip of code brought a compiler erro
1) typeid(T) - return const type_info& value and
this inconsistent with switch(...) - expression type
2) case(...) - expression in brackets should be const but in this case
its const referience[const type_info&]
I cant do an casting here because of type_info constructor
private.
*/
...
}
Can i avoid this error ,or i had to use if() statement,in this case.
THANKS
|
|
|
|
|
You can only switch on integral types - char , short , int , long (and their unsigned variants) and enumerated types.
You'll have to use an if statement in this case.
If you have to modify your processing based on the template parameter, then I don't thing you're really understanding the concepts of using templates. Read some articles or books on templates, particularly on partial template specialisation. "Modern C++ Design" by Andrei Alexandrescu is an extremely good book for learning about templates in depth.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
HI all
the setup i'm working on has the debugger out of step with the code.
Working in Visual C++.net.
If i set a breakpoint and step through the debugger thinks theres code where there is clearly whitespace.
I've cleaned and rebooted and rebuilt and all that but it doesn't seem to help.
There is only one copy of the source code on the hard drive and the build times are correct for all the files
I was wondering if anyone had any suggestions as to what might be going on and any solutions that might present itself.
regards
Bryce
---
Publitor, making Pubmed easy.
http://www.sohocode.com/publitor
|
|
|
|
|
Are you debuging a DLL? I have only come across this when the DLL I was debugging was not current!?
Ant.
|
|
|
|
|
Hi
Had this problem several times and got rid of it by cleaning the project first in Visual Studio and then going to the folder and deleting manually all remaining files generated by Visual Studio.
Cheers
Peer
|
|
|
|
|
which files specifically did you delete?
obviously i need to keep the .vcproj file...what else?
regards
Bryce
---
Publitor, making Pubmed easy.
http://www.sohocode.com/publitor
|
|
|
|
|
turns out some plonker had been opening the files ona unix box
guess what that did to the linefeeds etc
Bryce
---
Publitor, making Pubmed easy.
http://www.sohocode.com/publitor
|
|
|
|
|
i am trying to enumerate the whole network using RESOURCE_GLOBALNET arguement in the WNetOpenEnum(.,.,.,.,.) function. Program is not running properly it just gives me name of the first domain it finds and then the it terminates. When i use the RESOURCE_CONTEXT arguement in the WNetOpenEnum(.,.,.,.,.) i am able to get all the machines of the particluar sub domain, in which the application is running. For test purposes i am using the following code can any one point out the problem in this code
#include <iostream.h>
#include<windows.h>
#pragma message("network library is linking with \"mpr.lib\"")
#pragma comment(lib, "mpr.lib")
BOOL GetResources(NETRESOURCE *);
int main()
{
cout<<"hello"<<endl;
="" getresources(null);
="" return="" 0;
}
bool="" getresources(netresource="" *pnetresource)
{
="" dword="" dwscope="RESOURCE_GLOBALNET;
" netresource="" *netresource="NULL;
" handle="" henum;
="" wnetopenenum(dwscope,="" null,="" null="" ,="" pnetresource,="" &henum);
="" if="" (henum)
="" {
="" count="0xFFFFFFFF;
" buffersize="2048;
" lpvoid="" buffer="new" char[2048];
="" wnetenumresource(henum,="" &count,="" buffer,="" &buffersize);
="" netresource,="" for="" (uint="" i="0;" <="" sizeof(netresource);="" i++,="" netresource++)
="" (netresource-="">dwUsage == RESOURCEUSAGE_CONTAINER && NetResource->dwType == RESOURCETYPE_ANY)
{
if (NetResource->lpRemoteName)
{
if(NetResource->dwDisplayType == RESOURCEDISPLAYTYPE_DOMAIN)
{
cout<<endl<<"domain "<<="" netresource-="">lpRemoteName;
GetResources(NetResource);
continue;
}
cout<<endl<<"machine "<<netresource-="">lpRemoteName;
GetResources(NetResource);
continue;
}
}
GetResources(NetResource);
}
}
return true;
}
|
|
|
|
|
I massaged your code a little:
bool GetResources( NETRESOURCE *pNetResource )
{
DWORD dwResult;
NETRESOURCE *NetResource = NULL;
HANDLE hEnum;
dwResult = WNetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_ANY, 0, pNetResource, &hEnum);
if (NO_ERROR == dwResult)
{
NETRESOURCE Buffer[750];
DWORD Count = 0xFFFFFFFF,
BufferSize;
BufferSize = sizeof(Buffer);
do
{
dwResult = WNetEnumResource(hEnum, &Count, &Buffer, &BufferSize);
if (NO_ERROR == dwResult || ERROR_MORE_DATA == dwResult)
{
for (UINT i = 0; i < Count; i++)
{
if ((Buffer[i].dwUsage & RESOURCEDISPLAYTYPE_DOMAIN) == RESOURCEDISPLAYTYPE_DOMAIN)
cout << "Domain " << Buffer[i].lpRemoteName << endl;
else if ((Buffer[i].dwUsage & RESOURCEDISPLAYTYPE_SERVER) == RESOURCEDISPLAYTYPE_SERVER)
cout << "Server " << Buffer[i].lpRemoteName << endl;
else
cout << "Machine " << Buffer[i].lpRemoteName << endl;
if ((Buffer[i].dwUsage & RESOURCEUSAGE_CONTAINER) == RESOURCEUSAGE_CONTAINER)
GetResources(&Buffer[i]);
}
}
} while (NO_ERROR == dwResult || ERROR_MORE_DATA == dwResult);
dwResult = WNetCloseEnum(hEnum);
}
return true;
}
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
thanks David i am able to traverse the whole network quite successfully, but there is slight problem its showing no machines rather its showing machines as servers. So where would i have to make changes to make this code perfect..
|
|
|
|
|
The dwUsage member is going to have one of the following values:
RESOURCEDISPLAYTYPE_GENERIC
RESOURCEDISPLAYTYPE_DOMAIN
RESOURCEDISPLAYTYPE_SERVER
RESOURCEDISPLAYTYPE_SHARE
RESOURCEDISPLAYTYPE_FILE
RESOURCEDISPLAYTYPE_GROUP
RESOURCEDISPLAYTYPE_NETWORK
RESOURCEDISPLAYTYPE_ROOT
RESOURCEDISPLAYTYPE_SHAREADMIN
RESOURCEDISPLAYTYPE_DIRECTORY
RESOURCEDISPLAYTYPE_TREE
RESOURCEDISPLAYTYPE_NDSCONTAINER It's up to you to decide what a "machine" is.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Thanx David for your help
|
|
|
|
|
Hi,
I have a toolbar which has a variable amount of buttons. (the amount of buttons is determined at run time)
To send a message and to perform a function, OK, but then I have 1 function for more then 1 button, how can I let this function know which button is pressed?
tnx a lot for your help!
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimmy Hendrix
|
|
|
|
|
You might want to check ON_COMMAND_RANGE for this.
|
|
|
|
|
Hi folks,
I have the problem, that I want sent a bill as Email from a C++ Application over Outlook. So I want set the Email to plain text or alternative to set the font to Courier etc.
This is my Eample:
void CMyClass::SendEmail()
{
CString sStr, sMsg, sSubject;
_Application olApp;
COleException e;
double price1 = 100000;
double price2 = 20000;
if(!olApp.CreateDispatch("Outlook.Application", &e)) {
CString str;
str.Format("CreateDispatch() failed w/error 0x%08lx", e.m_sc);
AfxMessageBox(str, MB_SETFOREGROUND);
return;
}
_NameSpace olNs(olApp.GetNamespace("MAPI"));
COleVariant covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
olNs.Logon(covOptional, covOptional, covOptional, covOptional);
_MailItem olMail(olApp.CreateItem(0));
olMail.SetTo("test@domain.com");
olMail.SetSubject("My bill");
sStr.Format("Item1:%#30.02", price1);
sMsg += sStr;
sStr.Format("Item2:%#31.02", price2);
sMsg += sStr;
olMail.SetBody(sMsg);
olMail.Display(covOptional);
olNs.Logoff();
}
Who can help ?
|
|
|
|
|
Hi there,
When the user clicks on the Close or X button of a FormView, I would like a dialog box to appear asking if the user would like to save the changes. What function does the X button call when you close it so that I can write a function to override it? I realized that if I have a close button in my form, I can simply call PostMessage(WM_COMMAND, ID_FILE_CLOSE) to close it. But what if I do not want to just close the window but instead have it to do the same thing described above. How can I accomplish this?
Any help would be much appreciated! Thanks!
|
|
|
|
|
Try WM_SYSCOMMAND with nID parameter SC_CLOSE
When the user clicks on the Close or X button of a FormView, I would like a dialog box to appear asking if the user would like to save the changes
>
SetModifiedFlag(TRUE); //Of CDocument class
will do this for you.
|
|
|
|
|
I have several forms in the application that I would like to save to memory before writing all to disk. So the SetModifiedFlag() may not work in my case. There are two things that I would like to do. (1) When the user clicks on the Windows Close(X) button, what function do I need to override in order to do my custom save. Does a message call using WM_SYSCOMMAND with SC_CLOSE just closes the window? Depending on what function I override, it should be the same function I would use to call within my OnCancel() function when the user clicks on the Cancel button right? I am little confused on where and how the WM_SYSCOMMAND is used and if that is what I need.
Thanks!
|
|
|
|
|
I meant like this.You can map the WM_SYSCOMMAND for the MainFrame class.When the X button is clicked the value of nID will be SC_CLOSE.
void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam) <br />
{<br />
if(nID == SC_CLOSE)
{<br />
CSaveDlg SaveDlg;<br />
if( IDOK == SaveDlg.DoModal() )<br />
{<br />
}<br />
}<br />
CFrameWnd::OnSysCommand(nID, lParam);<br />
<br />
}
|
|
|
|
|
I inserted the following code in CMainFrame class but nothing happens when I close the form. The save dialog box should appear but it doesn't. Am I doing something wrong or am I not doing something?
Thanks!
void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam)
{
int save_button;
if(nID == SC_CLOSE) //Check If [X] Button
{
save_button = MessageBox(
"Save file",
"Save file data", MB_YESNO);
if (save_button == IDYES)
{
g_id->lp = lp_copy;
}
}
CFrameWnd::OnSysCommand(nID, lParam);
}
|
|
|
|
|
Code looks fine.Same thing works for me
But this will show the MessageBox when you are closing the main window.For the different FormViews you have to do this in the corresponding ChildFrame class.
Sorry
|
|
|
|
|
Can somebody give me good link that will give great information on -Remote Procedure Call.
I would like to know-
What are RPC based protocols.
What r the advantages of RPC
What r the disadvantages of RPC
Pls guide
|
|
|
|
|
Start here.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi
It is first message for you, because I regester in this site this month. Please talk to me about this site , its qualities , and other case of it.
Are you know the meaning of "MARZOGH"?
If YES,Please send for me.
|
|
|
|
|
mf14 wrote:
Please talk to me about this site , its qualities , and other case of it.
Well, its a site run for programmers by programmers.
It runs several forums dedicated to certain subjects. You posted this in the Visual C++ forum. You may have been better posting in the Lounge (see top right of browser window) to get better results.
It is also a great resource for articles on most if not all standard Microsoft technologies.
mf14 wrote:
Are you know the meaning of "MARZOGH"?
Sorry, cannot help with this one.
Roger Allen - Sonork 100.10016
Strong Sad: I am sad I am flying
Who is your favorite Strong?
|
|
|
|