Answer Questions
Howard Pinsley Pointers... when to use them?
In general, when do you use pointers It is my first time working on a more-complexed-than-hello-world application and I get many errors regarding "stack around variable x is corrupted" if I did not use pointers. eg: SomeDllClass sdcObj; sdcObj.doFunc(); ... // End of Function This gives me the stack corruption error. SomeDllClass* sdcObj = new SomeDllClass(); sdcObj->doFunc(); ... // End of Function This is OK. Also, I learned in my C++ Appreciation Class that pointers declared in a class should be deleted in the destructor. When I did that however, I was given a "Memory Access Violation" error (I initialized the pointer in a function other than the constructor). Is it advisable to use pointers for every variable I ...Show All
ChineduLB FindFirstFile returing wrong results
hi all , i used FindFirstFile function to search for files in folder and supplied a input as 'sea*' and though there is no file starts with sea still it is returing results as SEER_CSpringRight.xxx and SEER_ESpring_F_L.xxx .. Any help is appreciated . Hmm - I guess I saw what i wanted to see which was not sea - sorry. your code seems about right. But you should check the return value of FindFirstFile and only use wfFile if it didn't return INVALID_HANDLE_VALUE. As you say, that you get two matches the handle must be valid otherwise you shouldn't succeed in calling FindNextFile. Is that really excatly the code which produces the wrong find results -- SvenC ...Show All
imed-deborah Syntax for Overriding IListSource -Managed C++
I am having trouble with the syntax for overriding IList source in managed c++. Especially, how do you override the public ref class StopListSource : Component, IListSource { private: static BindingList<String^>^ blah = gcnew BindingList<String^>(); public: StopListSource() {} StopListSource(IContainer^ container) { container->Add(this); } //***The Following generates: a member using-declaration or access declaration is illegal within a managed type IListSource::ContainsListCollection { get { return false; } } //Not sure about the following, but it doesn't throw any errors //in C# this is: System.Collections.IList IListSource.GetList() , but in C++ this is old syntax ...Show All
Aravind_Sekar Run-Time Check Failure #2 - Stack around the variable
-------------MyClass.h file class CMyClass: public CDialog { ............ protected : HANDLE m_hDevMode; HANDLE m_hDevNames; HANDLE CopyHandle(HANDLE h) { if (!h) return NULL; BYTE* lpCopy; BYTE* lp; HANDLE hCopy; DWORD dwLen = (DWORD)GlobalSize(h); if (hCopy = GlobalAlloc(GHND, dwLen)) { lpCopy = (BYTE*)GlobalLock(hCopy); lp = (BYTE*)GlobalLock(h); CopyMemory(lpCopy,lp,dwLen); GlobalUnlock(hCopy); GlobalUnlock(h); } return hCopy; } ............ } // MyClass end ----------- MyClass.cpp file CMyClass::CMyClass(CWnd* pParent /*=NULL*/ ): CDialog(ClistareDlg::IDD, pParent) { m_hIcon = AfxGetApp()->LoadIcon(ID ...Show All
TheMaj0r Windows Service : Types HANDLE and HMODULE cause error :(
As I write a Windows service in C++, compiler doesn't reckognize types: HANDLE, HMODULE, WTSGETACTIVECONSOLESESSIONID and function GetProcAddress. Are there any libraries that should be included I only have the following libraries in my code: using namespace System; using namespace System::Collections; using namespace System::ServiceProcess; using namespace System::ComponentModel; Try this instead: HMODULE hmod = LoadLibrary( _T "kernel32.dll"); Hmmm - actually I cannot get from this article the information I need. E.g. it says to set Windows version, which is already done in windows.h library #ifndef WINVER #define WINVER 0x0501 #else #if defined(_WIN32_WINNT) && (WINVER < 0x0400) & ...Show All
Saad Ahmed CComboBoxEx image focus problem when item selected
I am using a CComboBoxEx to implement a image list and associated text, it works as expected, I am told. What I don't like is the 'blue highlight' that happens as I move the mouse over items, indicating this item is 'selected' or 'has focus'. Is there a way to get rid of this I have defined a 'selectedImage' and an 'Image' for each item, and even a 'maskImage' but I still get the blue highlight. K For such issues, the win32 dev newsgroups at http://msdn.microsoft.com/newsgroups is a more proper place. For the scope of these forums, please take a look at http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=19445&SiteID=1 OTP Thanks, Ayman Shoukry VC++ Team ...Show All
Satch78 Calling C# from unmanaged C++
I've been searching a bit and I'm just getting twisted around about what I need to do here. Apologies if this has been answered many times, but I haven't been able to find it. I have a C# class library containing a form called DisplayWindow. It is being built succesfully. Now, I'd like to be able to call my DisplayWindow form to load from some C++ code. Once loaded, I'll be making additional calls into the DisplayWindow from C++. I've seen some examples using COM, but that doesn't look quite like what I want to do. Also, I've seen some stuff for calling C++ from C#, and that looks much easier... Can anyone help with this Thanks! What you want to do would be to compile only the files where you want to load the C# code /clr and then ...Show All
JamaSaru TrayIcon : Shell_NotifyIcon
Hello, is it possible to use the Shell_NotifyIcon() function to add an icon in the tray taskbar with a DCOM server set to be launch by a specific local user (not the lauching user) The DCOM server exe is not a service. What append if the icon tray is created with any user logged on the server (remote client access) It is possible to create a icon tray that appears to evry user that connect to the server Thanks. This question is outside of the scope of this forum (Visual C++ 2005 as a tool, not COM or Windows API). Try asking your question in one of the MSDN Newsgroups like: http://msdn.microsoft.com/newsgroups/default.aspx dg=microsoft.public.win32.programmer.ui&lang=en&cr= ...Show All
manukahn visual c++ 2005 express edition button queestion
I had created a new form and I add a Button to it, but when I click on the button and I want to display a message i does not do it, also if I want to open another form using another button how i can do that in Visual C++ 2005 Exp. Ed. Juan Carlos private : System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) { Console::WriteLine( "Dame una mano" ); } Try: MessageBox::Show("My Message", "Dame una mano"); Instead of Console::WriteLine. ...Show All
FernandoLeite Thread (loops) and 100% CPU use
Hi, usually when we execute programs, they takes only the necessary CPU to execute, for example, when we run WINAMP, it only takes 10% or 15% CPU. But when I create a loop program, it always takes 100% CPU, for example, a program that executes sound (I use an OGG library): - I create the thread: bSoundReturn=false; //this controls when thread is terminated thSound=CreateThread(NULL,65536,PlayOGG,(LPVOID) hWnd,0,&thSoundID); - The message loop is as usual, it takes no CPU: while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } - And then, the loop is: DWORD WINAPI PlayOGG(LPVOID hWnd) { int i; bS ...Show All
Ogulcank Compile C++ code To .Bin File
Hi. can I compile C++ code with VC++ or VC.Net to a BIN file How thanks. The answer depends on what exactly is this .BIN file you are talking about. An EXE or DLL is a PE (portable executable) with a specific format. What is the format of this BIN you are talking about I know that exe & dll files are Binary Files. Moreover, EVERYTHING IS BINARY. Remember that. Nothing that you have on your computer is anything else than binary. So, yes, EXE and DLL are binary, but they follow a specific format, called Portable Executable . There are several questions you must clarify: why do you want to compile the program as a file with the extension .bin (I didn't say binary, because EVERYTHING IS BINARY) you can ...Show All
Microsuck Builds with IDE, but with msbuild LNK1104: can't find libc.lib??
I'm converting a VC6.0 console application to use 2005. I have one project that will build fine using the IDE, but when I use the command line: msbuild MyProject.vcproj /p:Configuration=Release ... I get a fatal link error LNK1104: cannot open file 'LIBC.lib' I'm new to Visual Studio and Windows applications in general. I did some searching and found the link error is likely caused because libc.lib doesn't exist past VS6.0, and this project is trying to link with a binary that was compiled with VS6.0. I'm not sure what exactly that means, but okay, sure. Per the suggestions of other posts, I made sure compiler switches /MD{d} are being used (the old workspace used /ML{d} ), then I tried telling the Linker Input to ignore libc.c. ...Show All
FC-Shiro File format
Hi all. Im having trouble making this file read-out look nice. The code is this: #include <fstream> using namespace std; int main(){ char buffer[100]; ifstream file("file.dat",ios::end); if(file.fail()){ printf("File not found.\n"); } printf("File contents read the following:\n"); while(file >> buffer){ printf("\n%s ",buffer); } file.close(); system("pause"); return 0; } The file "file.dat" reads "This is only a test" inside. But when i run the program it reads: File contents read the following: This is only a test ----------------------- So i figured maybe it was a problem with my way of printing the message in the console. So i sw ...Show All
LeoXue enum declaration - newbie can't do it! :)
i'm using VS C++ 2005 native, and I can't seem to get an enum declared. I can do it in a CLI app, but not native C++. There was a larger example in my book, but I can't get a simple app that ONLY declares the enum to compile. Here's the error. Following is my code. I know the enum declaration is in the main() function; I've also tried declaring just before the main() function. Thanks in advance for any suggestions/help! Brian Error: Error 1 error C3168: 'bool' : illegal underlying type for enum c:\documents and settings\<user>\my documents\visual studio 2005\projects\c++\enum_test\enum_test\enum_test.cpp 10 Code: // enum_test.cpp // #include "stdafx.h" #include <iostream> using n ...Show All
David McGraw ATL Stock Properties
Hi. I'm developing an ATL Control, (Composite Control), and now I want to add a stock propertie, ie BackStyle. How could I do that . Because there's not options for stock properties right clicking in the class view, (I'm using VC 6.0). At the time of add an ATL Object, there is a wizard that offer to add some stock propertie, but I did'nt in that moment, and now I need some of them. Thank you. These forums are specific for VC2005 issues. For VC6.0, please use the newsgroups at http://msdn.microsoft.com/newsgroups . OTP Thanks, Ayman Shoukry VC++ Team Ok Ayman. But the question also apply to VC 2005. It's about an ATL Control project not matter what Visual Studio involves. Thank you. ...Show All
