visual-c++

Add my own compiler warning

When using sprintf, the compiler warns me that the function is deprecated. How can I show my own compiler warning? ...

button keyboard focus issues

How would one prevent the little dotted square that appears on a button when it has the keyboard focus in a dialog. (w/ apologies for the technical jargon). At one point I hacked together a solution by subclassing a button WindowProc and subverting some windows messages, but wanted to know the correct way. There's actually a problem ...

how to use blitz_0.9

I down load blitz_0.9,I can build it in vs2008 and get blitzd.lib and blitz.lib but how can i get blitz.dll who have used it give me some advice thank you. ...

What should expericenced Unix programmer to be aware of using Microsoft Tools?

I come from UNIX world, I'm quite familiar with Linux, Solaris, Cygwin and MinGW development. Recently I ported one of my big projects (cppcms) to support MSVC, including building static and dynamic libraries with CMake. And I get all the time absolutely weird issues: I had CMake build issues because Windows programming lacks namin...

Converting a 1D pointer array (char) into a 2D pointer array (char) in Visual C++.

Hi All, I am new to c++ programming I have to call a function with following arguments. int Start (int argc, char **argv). When I try to call the above fuction with the code below I get run time exceptions. Can some one help me out in resolving the above problem. char * filename=NULL; char **Argument1=NULL; int Argument=0; int j = 0; ...

Why is "operator bool()" invoked when I cast to "long"?

I have the following class: class MyClass { public: MyClass( char* what ) : controlled( what ) {} ~MyClass() { delete[] controlled; } operator char*() const { return controlled; } operator void*() const { return controlled; } operator bool() const { return controlled != 0; } private: char* controlled; }; This is com...

Does GetModuleHandle function cause any leaks (stack overflow and memory leaks ) in VC++

I am using GetModuleHandle in my function. That function gets called every time I do an operation. I want to know if that function gets called again and again, will the GetModuleHandle cause any handle leaking (stack overflow or memory leaks or anything else). I actually know when it is getting called and when the break point is hit. But...

How to structure an application framework

I want to write something that will take care of: If possible the int main() loop, as in, I want the code for the main function located in this file Some mundane tasks like creating windows, initializing various things like opengl, opencv and what not. Various "events" (I quote because I what the c++ concept of events is) for things l...

Unable to copy data present in CMemFile using CMemFile::Detach()

I am writing two lines in memory using CMemFile::Write(): void CLISTCTRLDlg::Export(LPTSTR *pBlock) { CMemFile outMem(32768); CString csHeader = _T("EmpId EmpName EmpAddress\n"); outMem.Write(csHeader.GetBuffer(0), csHeader.GetLength()); CString csInfo = _T("1 TestName TestAddress\n"); outMem.Write(csInfo.GetBuffer(0), csInfo.Get...

How to use _CrtDumpMemoryLeaks()

I am trying to use _CrtDumpMemoryLeaks() to display memory leaks in my programs. But it does not display anything except for returning 0 in case of no memory leaks and 1 in case there is a leak. The link here shows the output should be like: Detected memory leaks! Dumping objects -> D:\VisualC++\CodeGuru\MemoryLeak\MemoryLeak.cpp(67) ...

CoInitialize() / CoUninitialize() calls pairing

I have a single-threaded application that uses COM objects. At the beginning I in effect call CoInitialize(0) twice - once in my code and the second time in the code of another subsystem of the application. The first call returns S_OK, the second returns S_FALSE - exactly as MSDN says. When the application stops it calls CoUninitialize(...

How does _ReadWriteBarrier propagate up the call tree ?

I'm looking at this bit of text in the documentation for Visual C++'s _ReadWriteBarrier intrinsic: In past versions of the Visual C++ compiler, the _ReadWriteBarrier and _WriteBarrier functions were enforced only locally and did not affect functions up the call tree. In Visual C++ 2005 and later, these functions are enforce...

How do I expose a C++ method to my C# application?

I am currently learning VC++. I have created an application that has functionality to block/allow IP addresses and I would like to expose this functionality to a C# application. I have defined the following members in my header file, which reference methods in my .cpp file (bare with me if that's obvious, as this is my second day of C+...

how can I fix the MSVC 2005 error: unresolved external symbol __environ

Hi, In my application, I need direct access to the _environ variable because I must have something like the glibc unsetenv (you cannot have that with setenv or putenv). This is the code I need to use: ////////////////////// // unsetenv for WIN32, taken from libc source int unsetenv(const char *name) { size_t len; char **ep; if ...

Memory leaks in Debug mode

Is there any reason for a program to leak when compiled in Debug mode and not in release? (Debug means debug informations, and compiler optimization disabled, Release means no debug info / full optimization) That's what it seems to do but I can't figure out why. Btw purify is not being helpful here ...

Is it possible to make Visual Studio C++ 2008 check for errors as you type like Eclipse?

To be more precise, when I used eclipse for java, every time I typed it would check for errors. For example, if I typed a line and forgot a semi-colon, eclipse underlined the area in red and gave me an error, same with misspellings, variable names that have not been defined, etc, etc, etc. I'm now using Visual Studio 2008 (as the teache...

Successful when executing VS 2005 project in Debug mode but failed in MinRelease mode

Hi, I developed a ClassLibrary in VC++ using VS 2005. Later I registered the dll, i got from building the project in MinRelease mode and when i tried to execute my application it failed. But the same application got executed successfully by registering the dll that i got from building the project in Debug mode What is the issue.? ...

What happens if I call GlobalLock(), then fail to call GlobalUnlock()?

In Win32 in order to paste data into the clipboard I have to call GlobalAlloc(), then GlobalLock() to obtain a pointer, then copy data, then call GlobalUnlock() and SetClipboardData(). If the code is in C++ an exception might be thrown between calls to GlobalLock() and GlobalUnlock() and if I don't take care of this GlobalUnlock() will ...

visual c++ inner class as a property, possible ?

Hello, As a C++ programmer I've recently started to work with visual c++. I've get stuck with the properties. The idea is to create an inner class that would have 2 methods plus property like get/set functions. Does it even possible in visual C++ (i guess yes). The usage would be like this: Foo ^ foo = gcnew Foo(); int a; foo->Metho...

Visual C++ Automatically Appending A or W to end of Function

In C++ I have defined a class that has this as a member static const std::basic_string<TCHAR> MyClass_; There is also a getter function for this value LPCTSTR CClass::GetMyClassName() { return MyClass_.c_str(); } When I create an instance of this class and then try and access it intellisense pops up but the name has been change...