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

#5291758 Obtain Task Bar Docking Setting: Always returns ABE_LEFT

Posted by on 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);

#5272649 Software that use Component Based Architecture

Posted by on 25 January 2016 - 08:31 PM


Thanks for your answer. I have made a CBA API and I am looking for ideas of applications to create with it. Do you know of any companies or applications that predominantly use CBA in  its 'pure' form (ie not as a base for an OOP application)?

Which of the twenty different ""pure"" forms are you referring to?



Leave it up to us C++ devs to overthink a simple question and veer off on a completely different tangent.


If I were to ask 'What well known software products/applications use OpenCV?'; an answer is 'Tesla's driving software heavily relies on it'. Cue the counter argument that the op question is not clear enough, thus, requires defining what someone means by 'pure', 'well-known', 'CBA', 'the', 'I' and etc. An then we find us.... on a tangent.

#5268659 Fun Challenge: Implement Polymorphic Callback

Posted by on 31 December 2015 - 06:30 PM

Hi, I am implementing Component Based Architecture in my application and have recently run into a problem. The problem could be easily solved by using std::function although as a fun project I would like to try and tackle this problem without using std::function (even if that means ending up implementing my own version of std::function).



I'm at the stage where I need to allow a Component to specify a callback that will be executed upon an event.

typedef void(Component::*EventCallback) ();
typedef std::pair<Component*, EventCallback> EventDelegate;


The problem with the above type definition is that all components inherit from Component but will never be a direct Component. So the following line of code is not valid:

MoveComponent* mc = new MoveComponent(); // inherits from Component
EventDelegate ed(mc , &MoveComponent::moveToXY); // Not valid because it expects Component* not MoveComponent*, and same for EventCallback.


Any ideas on techniques and approaches that could achieve this?  Some approaches I am thinking of... any obvious/other solutions I have missed?

typedef void* EventCallback; // lazy solution 

// or

// Psuedo code (I've considered using templates here but its doesn't seem to be a solution)
class EventDelegate
	// DataType = Pointer to component type (eg MoveComponent) 
	// Func		= Pointer to component function 
	// Context	= Pointer to component

	void runCallback()
		(Context->*(void(DataType::*Func)) ();

std::unordered_map<EVENT, EventDelegate> evtRegistry;


Current (simplified) implementation:

typedef void(Component::*EventCallback) ();
typedef std::pair<Component*, EventCallback> EventDelegate;

class Component {
    // ...

class MoveComponent : public Component {
    MoveComponent() {

        EventDelegate ed(this, &MoveComponent::moveToXY);

    void moveToXY() { }

class ComponentManager {

    static void registerEvent(EventDelegate ed) {

    static void runEvent(EventDelegate ed) {
        for (int i=0; i<evtRegistry.size(); i++) {
            Component* context = evtRegistry.at(i).first;
            EventCallback ec = evtRegistry.at(i).second;

    static std::vector <EventDelegate> evtRegistry; // vector for a simple example. Really a std::unordered_multimap<EVENT, EventDelegate>

#5174894 Is the BIOS Serial Number Always Set, Constant & Reliable

Posted by on 19 August 2014 - 07:23 PM



I am thinking of using the users BIOS/Motherboard Serial Number to uniquely identify a user (the application runs on Windows OS). When I refer to the BIOS/Motherboard Serial Number I am referring to the serial number returned when you type in: wmic BIOS get SerialNumber


I have previously attempted to use the Hard Drive serial number to uniquely identify a user but WMI is notoriously unreliable. For example; if you are running your .exe as an elevated process you will get a different Hard Drive serial number back from WMI. Also as crazy as this sounds, I have had 2 different Windows 8 machines change their Hard Drive serial no. on me when the Hard Drives were not changed at all - I'm not crazy this really happened - I realise there's no better way for people to think you're crazy than saying 'I'm not crazy' but putting that aside - do you know if I will experience these same issues with the BIOS/Motherboard' Serial Number?


Some queries

  • Can the user change this serial number? Either using third party applications or through Windows.
  • According to this forum post, not all vendors supply a motherboard UUID so I cannot use this to uniquely identify the user. Do venders mostly/always supply/fill out the BIOS/Motherboard Serial Number or will I also find some computers dont have a serial number?
  • I have tried to uniquely identify a user using the Hard Drive's Serial Number. But I have run into the issue that the serial number can change and that Windows API is unreliable and can return different values. Do you know if I may experience the same issue for the BIOS/Motherboard's Serial Number?
  • Can a standard process (Standard Windows User) retrieve the BIOS/Motherboard Serial Number? Or does the process need to be elevated (Admin User)?
  • What would happen if the user has a virtual machine?

Just to confirm the BIOS is the motherboard, correct? I am a little unclear because I thought the BIOS is the simple software installed on the motherboard.


#5168087 Thinking in Javascript

Posted by on 21 July 2014 - 12:43 AM

I tend to learn programming easier by thinking up something I want to achieve then attempting to code it (and asking questions about 'How to do...' along the way) rather than reading books and doing exercises. Thats how I learnt/am learning Javascript. But this may not be how you learn.


But if you do, I'd try to do something like 'Move a div from the left of the screen to the right' or 'Get some XML from a server'.


Javascript is really powerful because there isn't quite anything called a class, yet you can still achieve sub-classing, polymorphism and abstraction.


An example is:

var someVariable= {"key": "value"}; // this a map

someVariable["Anonymous Function"] = new function(someParams) {

// call anonymous function
someVariable["Anonymous Function"]("blah");

someVariable = [1, 2, 3]; // this is now an array

// I think you can do this also but may need to check
someVariable = {someProperty: 1.1};
console.log(someVariable.someProperty);  // almost treat the variable as a class with properties.

#5112008 Insert Image into SQLite3 Database: Unsure whats causing the error

Posted by on 25 November 2013 - 07:49 PM

First of all, SQLite doesn't care whether your blob is a valid PNG image.

Second, please try to understand what you are doing.
"Someone advised me to use byte[] instead of a string or etc" is not a matter of opinion: the function you are trying to call is declared as int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*)), you cannot pass what you want as a parameter.

Third, RTFM.
Why are you goofing around with DllImport instead of using the proper .Net wrapper (system.data.sqlite.org)? Code examples like http://stackoverflow.com/questions/625029/how-do-i-store-and-retrieve-a-blob-from-sqlite are easy to find.


You're pretty rude and thats putting it politely. Dont assume I haven't read the ******* manual because I have (I am aware of a much simpler way to achieve what I am trying to do, ie, use system.data.sqlite). I am using Unity3d where you cant use system.data.sqlite.org so you are forced to use the C API, this may have changed in the latest release of Unity3d though.


I'll accept that you (incorrectly) assumed my ignorance but I dont accept your aggressive condescending demeanour. You were never obliged to reply to my thread so there's no reason to be angry and I'm telling you, dont reply to my threads in the future.

#4879152 Extract the R, G, B values from a Flash decimal number

Posted by on 31 October 2011 - 11:56 PM


I have colour values from a Flash application that are ARGB format(A being the alpha/transparency value).

I have to convert that long decimal number to a RGB/Hexadecimal number in Javascript. I REALLY struggle with bitwise operations. In Flash the colour white is represented by the decimal number: 16777215, black is obviously 0. Other colours are like: 84545883, 4803910 etc which I have no idea what colour they are.

Do you know how I can extract the individual R, G, B & A values from a long(8 digit) number?

Can you help me get these functions to extract the (R,G,B,A) values?

function getA( num )
   // eg value for num is 84545883
   return (parseInt(num,10)) & 0xFF000000;  // does this correctly get the A value from a ARGB value?

function getR( num )
   // eg value for num is 84545883
   return (parseInt(num,10)) & 0x00FF0000;  // does this correctly get the R value from a ARGB value?

function getG( num )
   // eg value for num is 84545883
   return (parseInt(num,10)) & 0x0000FF00;  // does this correctly get the G value from a ARGB value?