c++

How can I make only a part of the window transparent? (WIN32)

How can I make for example only a rectangle inside the window have opacity like 50% or something like that and for that part to have the effect of WS_EX_TRANSPARENT so that mouse clicks will go through it? ...

C# to unmanaged C++

I have created 2 structures in my C# code : [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public class RollInformationCSharp { [MarshalAs(UnmanagedType.R8)] public double rollDiameter; [MarshalAs(UnmanagedType.R8)] public double initialRoughn...

Int tokenizer

I know there are string tokenizers but is there an "int tokenizer"? For example, I want to split the string "12 34 46" and have: list[0]=12 list[1]=34 list[2]=46 In particular, I'm wondering if Boost::Tokenizer does this. Although I couldn't find any examples that didn't use strings. ...

Routine to check if a given date is summertime or wintertime

Do you know if an API exists for that checking? ...

How do I load a shared object in C++?

I have a shared object (a so - the Linux equivalent of a Windows dll) that I'd like to import and use with my test code. I'm sure it's not this simple ;) but this is the sort of thing I'd like to do.. #include "headerforClassFromBlah.h" int main() { load( "blah.so" ); ClassFromBlah a; a.DoSomething(); } I assume that t...

How to return const Float** from a C++ function

I have a class which hold an array "float ** table". Now I want to have member function to return it, but don't want it to be modified outside of the class. So I did this: class sometable { public: ... void updateTable(......); float **getTable() const {return table;} private: ... float **table; } This compiles O...

What if the default parameter value is defined in code not visible at the call site?

I've found some strange code... //in file ClassA.h: class ClassA { public: void Enable( bool enable ); }; //in file ClassA.cpp #include <ClassA.h> void ClassA::Enable( bool enable = true ) { //implementation is irrelevant } //in Consumer.cpp #inclide <ClassA.h> .... ClassA classA; classA.Enable( true ); Obviously since Consum...

Waiting for ShellExecuteEx (Setting access rights on Windows process)

Hi, I'm using the ShellExecuteEx function in a C++ program to launch an Uninstall.lnk file. In my program, I'd like to wait for the uninstaller to finish. My first attempt was to set the SEE_MASK_NOCLOSEPROCESS flag in the SHELLEXECUTEINFO structure and then call WaitForSingleObject on the hProcess handle available in the SHELLEXECUTEIN...

is there a way to have midl generate each interface in a separate .h ?

I have a bunch of objects that inherit abstracts interfaces generated from an idl file. Each object that use of theses interfaces include the same file interfaces.h which contain all the c++ generated abstract classes that map to the idl interface. Each time I change anything into interfaces.idl every classes that depend on this have to...

C++ : Will compiler optimize &Variable; away?

In C++ a statement like this is valid: &Variable; IMO it doesn't make any sense, so my question is, if you do this, will it affect the compiled result in any way, or will the compiler optimize it away? Thanks! ...

Saving QPixmap to JPEG failing (Qt 4.5)

Hello. I have the following code. QString fileName = QFileDialog::getSaveFileName( this, tr("Output Image file"), (""), tr("PNG (*.png);;JPEG (*.JPEG);;Windows Bitmap (*.bmp);;All Files (*.*)") ); if(fileName != "") { QwtPlot* pPlot = ... QSize size = pPlot->size(); QRect printingRect(QPoint(0, 0), size); QPi...

What are the best blogs for staying up to date on C#, ASP.NET, LINQ, SQL, C++, Ruby, Java, Python?

Apologies if this repeats another - but I couldn't fine one like it. My day to day programming spans a fair number of technologies: C#, ASP.NET, LINQ / SQL, C++, Ruby, Java, Python in approximately that order. It's a struggle to keep up to date on any of best practices, new ideas, innovation and improvements, let alone all. Therefore,...

If an operator is overloaded for a C++ class how could I use a default operator instead?

_com_ptr_ has an overloaded operator&() with a side effect. If I have a variable: _com_ptr_t<Interface> variable; How could I retrieve its address (_com_ptr_t<Interface>* pointer) without calling the overloaded operator and triggering the side effect? ...

How do use a std::auto_ptr in a class you have to copy construct?

I have class foo that contains a std::auto_ptr member that I would like to copy construct but this does not appear to be allowed. There's a similar thing for the assignment. See the following example: struct foo { private: int _a; std::string _b; std::auto_ptr< bar > _c; public: foo(const foo& rhs) : _a(rhs._a...

C++ template function that uses field present in only some data-types?

Is it possible to have a C++ template function which can access different fields in its input data depending on what type of input data was passed to it? e.g. I have code of the form: typedef struct { int a; int b; }s1; typedef struct { int a; }s2; template <class VTI_type> void myfunc(VTI_type VRI_data, bool contains_b) { pr...

ReadDirectoryChangesW thinks shortcut is being deleted right after creation

Hi, I am using this implementation of ReadDirectoryChangesW to monitor changes to the desktop. My program plans to run some small program when a file is created on the desktop. Now the problem I am running into is when I create a new shortcut via the right click context menu ReadDirectoryChangesW gets a notification saying the file ha...

what is the difference between const int*, const int * const, int const *

I always mess up how to use it correctly. Is there a set of rules defining what you can and cannot do? I want to know all the Do's and all DoNOTs in terms of assignments, passing to the functions, etc. Thanks ...

How to concat two or more gzip files/streams

Hello, I want to concat two or more gzip streams without recompressing them. I mean I have A compressed to A.gz and B to B.gz, I want to compress them to single gzip (A+B).gz without compressing once again, using C or C++. Several notes: Even you can just concat two files and gunzip would know how to deal with them, most of program...

File corruption detection and error handling

I'm a newbie C++ developer and I'm working on an application which needs to write out a log file every so often, and we've noticed that the log file has been corrupted a few times when running the app. The main scenarios seems to be when the program is shutting down, or crashes, but I'm concerned that this isn't the only time that someth...

#pragma once vs include guards?

I'm working on a codebase that is known to only run on windows and be compiled under Visual Studio (it integrates tightly with excel so it's not going anywhere). I'm wondering if I should go with the traditional include guards or use #pragma once for our code. I would think letting the compiler deal with #pragma once will yield faster co...