|
Hi,
Please can someone help me with this stupid problem. I want to use a vector on this way: vector<cstring> StringVector.
I get the follow errors and have the vector included on this way: #include <vector> in the header.
error C2143: syntax error : missing ';' before '<'
error C2501: 'vector' : missing storage-class or type specifiers
etc..
thanks,
Willem
|
|
|
|
|
Hi!
This message looks like a not correct included header file.
Maybe another .h file ,loaded before, is not correct "finished" (missed to set a ; )
You should check the order of the .h files you include.
What kind of type is vector?
Maybe it is a class name in another .h file?
Bye FatBastard
|
|
|
|
|
The < characters have been eaten! Next time tick on the "Notify me by e-mail if someone answers this message" check box before submitting your post.
As for your problem, you've got to define your vector type as
std::vector<CString> StringVector; Regards,
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I think you need to add the followin line:
using std::vector;
Best regards,
Alexandru Savescu
P.S. Interested in art? Visit this!
|
|
|
|
|
Guys,
What would cause my PC's graphic display to behave all funny and the system eventually to crash?
Are there any tools that would be able to give me some kind of direction in locating the problem.
What can I do using MS VC++ tools.
The program that I run is quite big with 65 threads, a plethora of supporting files, MDI interface, and dialog boxes.
I am running NT with Service Pack 6.0, VC++ 6.0
Any general advice will be appreciated.
Thanks
Louis
|
|
|
|
|
louis wrote:
What would cause my PC's graphic display to behave all funny
The problem may come from the use of graphical objects (as pens or fonts), selected in a device context which is released without reassigning before the original GUI objects.
For example, the following (dummy) code is wrong:
{<br />
CDC myDC;<br />
CPen myPen;<br />
<br />
myPen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));<br />
myDC.SelectObject(myPen);<br />
myDC.LineTo(0, 0);<br />
}
This one is good
{<br />
CDC myDC;<br />
CPen myPen;<br />
CPen *pOldPen;<br />
<br />
myPen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));<br />
pOldPen = myDC.SelectObject(myPen);<br />
myDC.LineTo(0, 0);<br />
myDC.SelectObject(pOldPen);
}
HTH,
Ohé Partisans, Ouvriers et Paysans
C'est l'alarme!
Le Chant des Partisans
|
|
|
|
|
Thank you very much.
Your advice is highly appreciated.
I have gone thru the graphical objects as suggested.
All code seem to be implemented the correct way.
I intent to go thru it again to confirm.
An interesting comment by someone else is to monitor the GDI Objects in Task Manager. I however are unable to activate it in NT. Any advice here.
Thanks.
Louis
|
|
|
|
|
We had this very same kind of problem in one of our apps. We knew it was caused by a resource leak, but I had spent weeks trying to fix it. All GDI objects I allocated were check/destroyed etc, but it still persisted until quite recently when we found the culprit:
SHGetFileInfo(path, 0, &fileinfo, sizeof(fileinfo), SHGFI_ICON | SHGFI_SMALLICON | SHGFI_SHELLICONSIZE);
It seems that this system procedure allocates an icon that you need to destroy yourself. If your using this call make sure you call the corresponding DestoryIcon() on the member var listed in the MSDN fo a SHFILEINFO object.
Roger Allen
Sonork 100.10016
In case you're worried about what's going to become of the younger generation, it's going to grow up and start worrying about the younger generation. - Roger Allen, but not me!
|
|
|
|
|
Thank you very much.
I do appreciate your advice.
I have gone thru your suggestions.
All code are implemented the correct way, i.e all are destroyed afterwards except for one occurence. This i have corrected but the problem still remains.
An interesting comment by someone else is to monitor the GDI Objects in Task Manager. I however are unable to activate it in NT. Any advice here.
Thanks.
Louis
|
|
|
|
|
I've had this same problem myself. You have a resource leak (as others have noted). If you want to debug your resource consumption, you can use the task manager. Now, I'm not sure that this is the same in NT, but under Win2K open the Task Manager and select the "Process" tab. Then click the "View | Set Columns..." menu item. In the resulting dialog, make sure you have "GDI Objects" checked and click "Ok". Now, run your application and watch the "GDI Objects" column. You will, in all liklihood, see your object count go up to something like 8000 or 9000 and then crash. At least that's what happened to me.
As others have noted you need to release your resources when you're done using them including any new DCs you've created. Make sure you call ReleaseDC on any new DCs you've created with CreateCompatibleDC, or any other DC creation mechanism, when you're done with it. This is where the vast majority of my problems were. Once I fixed them all, my app only used 34 GDI objects (on average).
Hope this helps.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
Hi Everybody,
I work in VC++(MFC). I wish to block the internet access of a machine. The machine can be connected to the internet through a dial up connection or a cable internet connection. Can anybody help me in achiving this.
Thanking all in anticipation.
Regards,
Onkar
|
|
|
|
|
I think that you're asking this question in the wrong forum. Actually, I'm not so sure that you've got the right web site. Your question relates more to networking--specifically IP filtering. This type of thing is usually accomplished with hardware such as a router. If you don't have control over the hardward or the network domain, I think that you're out of luck. I personally use a Linksys cable/dsl router that provides IP filtering on the firmware. This allows me to determine which IPs can surf the internet and which can't.
This could probably be accomplished by writing code and puting a computer running that code between the computer you want to block and the internet, but why would you want to do that. Decent hardware to accomplish the same is cheap.
Anyhow, I think you've got the wrong forum. Good luck, though.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
For a dialout connection, I guess you could just keep the port
on which the modem is attached open (hence unavailable).
For a NIC, hmm... maybe you could open
every socket (all 65536 of them)
and keep them open as well?
|
|
|
|
|
int WideCharToMultiByte(
UINT CodePage, // code page
DWORD dwFlags, // performance and mapping flags
LPCWSTR lpWideCharStr, // wide-character string
int cchWideChar, // number of chars in string
LPSTR lpMultiByteStr, // buffer for new string
int cbMultiByte, // size of buffer
LPCSTR lpDefaultChar, // default for unmappable chars
LPBOOL lpUsedDefaultChar // set when default char used
);
cchWideChar is int so it must less than 65535.But I have BSTR the data is large than 65536. How can I convert to char.
Pz give me some hints.
THX.
|
|
|
|
|
It's a short that needs to be less than 32767, or 65535 if it is unsigned.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
O. yes.int needs to be less than 32767. Then it more hard to convert WideChar to MultiByte. Have any way to do this ?
|
|
|
|
|
*short* needs to be less than 32767. int needs to be less than 65535 * 32767. Have you tried it ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
char* fname;
int n_n = MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,fname,-1,NULL,0);
LPWSTR yty; yty = (LPWSTR)malloc(n_n * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,fname,sizeof(fname),yty,n_n);
|
|
|
|
|
Hi
Has anobody tried to use the "Microsoft Forms 2.0 Frame Control" in VC++? It seems to not work properly when I call the property "GetObject": it gives me a useless Idispath because I can't access to the props and methods of the control. This only happen when inserting a custom control (the Calendar control for instance)in the Frame control.
Any clue?
|
|
|
|
|
Hello,
I have to get the value of the an Excel cell into a stand alone MFC app.
The excel file is already opened. I do not need an excel file reader.
What I'd like is to connect to an already opened xl and periodically read a specific cell.
I have no clue where to start from what technology to use.
Any direction/hint/source code more that welcomed.
thx.
|
|
|
|
|
Are you willing to use Office Automation? That is probably your best bet, but when you build the app that uses office automation, it is dependant on a specific version of Excel. Here's the main page on MSDN for office automation docs:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnoffdev/html/vsofficedev.asp
Once you're there, click on the link called "Visual C++/MFC - Information and Sample Code". Once there, you just scroll a bit to a sub heading called "Microsoft Excel Automation". You'll find several examples there that should help you get going. The first one looks like it may help you http://support.microsoft.com/default.aspx?scid=KB;en-us;q179706
Good luck.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
Hi !
My app (VC6) is an ATL object, and I would like, during the initialization of the object, to create a window and to post messages to this window. Right now, the only thing the app is doing is to display a message box when a message is received....nad it doesn't work !!!
Here is what I'm doing :
Here is my window class :
<br />
#include "atlwin.h"<br />
#define WM_MYMESSAGE WM_APP+1<br />
<br />
class CMyWindow : public CWindowImpl<CMyWindow><br />
{<br />
public:<br />
CMyWindow(){};<br />
virtual ~CMyWindow(){};<br />
DECLARE_WND_CLASS("MyWindow") <br />
<br />
BEGIN_MSG_MAP(CMyWindow)<br />
MESSAGE_HANDLER(WM_MYMESSAGE, OnMyMessage)<br />
END_MSG_MAP()<br />
<br />
LRESULT OnMyMessage(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& Handled)<br />
{<br />
::MessageBox(NULL,"Message","Message",MB_OK);<br />
return 0;<br />
}<br />
};<br />
and here is my interface code (in the class declaration, I just added a member of type CMyWindow*) :
<br />
CEventBox::CEventBox()<br />
{<br />
m_pMyWindow=new CMyWindow;<br />
RECT myRect;<br />
myRect.bottom=100;<br />
myRect.left=0;<br />
myRect.top=0;<br />
myRect.right=100;<br />
m_pMyWindow->Create(NULL, myRect, NULL, 0, 0, 0U, NULL);<br />
}<br />
<br />
STDMETHODIMP CEventBox::SendEvent(long lNbrEvent, long lSpaceTime)<br />
{<br />
PostMessage(m_pMyWindow->m_hWnd,WM_MYMESSAGE,0,0);<br />
return S_OK;<br />
}<br />
For my tests, I try to use this ATL object in a VB project, where I call the method 'SendEvent' of the interface. Nothing crashed but I cannot see the window I created in the constructor of CEventBox and the message box of OnMessageBox is never displayed.
Any help will be greatly appreciated !
Thank you !
Jerome
|
|
|
|
|
Hi,
I like to create a nice looking icon list (similar to this).
I'm not skilled in GUI programming, so I like to ask for help. How about creating an empty CDialog , then dynamlically create and position all my icons and texts (icons can vary on runtime). Well, this would be similar to HTML and a scripting language filling the page with icons and text.
I have two questions:
1. Where do I create my controls, OnInitDialog() or PreSubclassWindow() ? Sumthing I have too look at?
2. How do I get a scrollbar when controls do not fit into the dialog? For example when I have lots of icons, then the dialog should automatically show a vertical scroll bar.
Thanks for pushing me into the right direction.
|
|
|
|
|
|
My company has a NT domain server, connected by Windows 9x/Me clients. I want to write a program checking the user's group for authorization. Which WinAPI function can provide such information for window 9x/Me clients? Thanks.
Ruxo Zheng
|
|
|
|
|