Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 27 Dec 2009
Offline Last Active Sep 23 2016 08:10 AM

Posts I've Made

In Topic: Pre-emptive Solution for 'The application was unable to start correctly (...

15 August 2016 - 12:41 AM

Are you compiling for 64-bit or just compiling on a 64-bit Windows installation?


I am compiling just using the 32bit static libraries (on my 64bit Windows 8.1 OS) in the hopes that I can just cover everyone (correct me if I am wrong about this?). My application is a simple WinAPI c++ utility application. So it's small (<800kb) so it doesn't make sense to distribute the visual c++ redistributable package with my installer. What I am hoping is to package all dependencies (I only use static libraries) into my .exe if possible.

In Topic: Pre-emptive Solution for 'The application was unable to start correctly (...

14 August 2016 - 11:16 AM

I am linking the static OpenSSL libraries so shouldn't I not need to distribute the dll with my installer? Shouldnt it be packaged into the exe?


My Linker->Input->Additional Dependencies are:










In Topic: Obtain Task Bar Docking Setting: Always returns ABE_LEFT

15 May 2016 - 08:30 PM

Looks like I was using the wrong flag. The following works:

APPBARDATA barData {0};
barData.cbSize = sizeof(APPBARDATA);
UINT_PTR res = SHAppBarMessage(ABM_GETTASKBARPOS, &barData);

In Topic: HINSTANCE & HWND Corrupted when passed around functions

17 April 2016 - 10:10 PM

After extensive debugging I have found the problem and solved it. It's actually quite interesting what went wrong. The problem was here...

struct IEventArgs


struct WinEventArgs : public IEventArgs
    WinEventArgs() = delete; 
    WinEventArgs(const HINSTANCE& hinstance, const HWND& hwnd, const WPARAM& wParam, const LPARAM& lParam) :
        hinstance(hinstance), hwnd(hwnd), wParam(wParam), lParam(lParam)

    const HINSTANCE& hinstance;
    const HWND& hwnd;
    const WPARAM& wParam;
    const LPARAM& lParam;

class EventDelegate
        // the problem is here: the parameter should be 'const IEventArgs&'
	typedef std::function<Status(IEventArgs)> EDelegate;

	EventDelegate(EDelegate delegate, GUID gUidContext);

	Status operator()(const IEventArgs& evtArgs)
            return delegate(evtArgs);

	GUID gUidContext;
	EDelegate delegate;

I've produced a simple example of the problem that people can reproduce. Whilst I've fixed it, what exactly was going wrong, was it that a copy was being made and I hadn't implemented a copy constructor?

struct IEventArgs {  };

struct WinEventArgs : public IEventArgs
	WinEventArgs(const int& a, const int& b) : a(a), b(b) { }
	const int& a;
	const int& b;

class Component
	void test(const IEventArgs& evtArgs)
		const WinEventArgs& args = static_cast<const WinEventArgs&>(evtArgs);
		printf("a=1 is: %d, b=2 is: %d\n", args.a, args.b);

int main()
	WinEventArgs args(1,2);
	Component cmp;
	// Note Component::test's parameter is 'const IEventArgs&' and that the std::function parameter is just 'IEventArgs'
	std::function<void(IEventArgs)> func = std::bind(&Component::test, cmp, std::placeholders::_1);
	// When std::function parameter is 'const IEventArgs&' the cast inside Component::test succeeds
	std::function<void(const IEventArgs&)> func2 = std::bind(&Component::test, cmp, std::placeholders::_1);
	return 0;

In Topic: HINSTANCE & HWND Corrupted when passed around functions

17 April 2016 - 12:59 AM

I am specifying a reference; const WinEventArgs& args = static_cast<const WinEventArgs&>(evtArgs);


One thing that could be the cause is that; LRESULT CALLBACK Win32App::wndProc(..) is a static function. Therefore when it creates the WinEventArgs object it is also static aswell. The last time the WinEventArgs object is valid is inside EventDelegate::operator()(const IEventArgs & evtArgs) - not a static function.

// Static class function
LRESULT CALLBACK Win32App::wndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    int wmId, wmEvent;
    HDC hdc;

    WinEventArgs args { hinstance, hwnd, wParam, lParam };
    eventHandler(message, args);  // also static function: IApp::eventHandler(const int & evtId, const IEventArgs & evtArgs)