Posting requesting multiple products with inAppPurchaseManager

August 26th, 2013

Documentation for inAppPurchaseManager is poor at best. Here’s how to initialize with multiple products:
window.plugins.inAppPurchaseManager.requestProductsData(["myproduct1", "myproduct2", "myproduct3"], function(feedback)
{
for (var c=0; c<feedback[0].length; c++)
console.log(“Succeded: “+feedback[0][c]['id']);

for (var c=0; c<feedback[1].length; c++)
console.log(“Failed: “+feedback[1][c]);
});

inAppPurchaseManager and config.xml

August 26th, 2013

Just a short note because I found it nowhere else on the net:

If you’re getting this error:
ERROR: Plugin ‘InAppPurchaseManager’ not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.

You’ll need these magic words to integrate inAppPurchaseManager into your config.xml:
<feature name=”inAppPurchaseManager”>
<param name=”ios-package” value=”InAppPurchaseManager”/>
</feature>

Storing crash relevant information

June 22nd, 2013

Sometimes it’s helpful to store debug information on a regular basis somewhere and recover it if the program is crashed and restarted to get info about the cause of the crash. Unfortunately, there’s no perfect way for storing this data in Windows. And you don’t want to slow down your program to much. So I tried a benchmark and compared RegSetValueEx against SetFilePos(0) + WriteFile. (In both cases the handle was opened just once then used for writing 100.000 times.

And it turned out that WriteFile is 10x faster. More interesting facts:

- FILE_ATTRIBUTE_TEMPORARY didn’t change a thing.

- My SSD is fast (298ms), but my hard disk is faster (268ms, don’t ask me why) and my Ramdisk faster than both (206ms).

Dangerous MakeLower

May 2nd, 2013

Got weird crashes at customers with foreign languages? Microsoft’s MFC’s MakeLower could be the culprit. Seems to be poorly written because it can crash if it doesn’t like the string. I could even reproduce it here by switching the Windows-Locale for non-unicode apps the Japanese and process some strings contains German umlauts. Bottom-line? Don’t use, write your own… :-(

Google correlates with county jail

March 21st, 2013

By accident I stumbled across a new Google trick called Google Correlate which looks for data that correlates with the search term that you enter. I didn’t really know what this is good for, so I just entered “Google”. And guess what: Google correlates with county jail.

Like all statistical data, it’s up to the reader to interpret it.

 

Google Correlate

 

Using Visual Studio 2012… Safely…

January 10th, 2013

Microsoft Visual Studio 2012 isn’t so bad. ;-) I actually even like new dark looks. But (for C++) you shouldn’t use the default settings, our you’ll get problems with your older customers.

 

1. Making it run with XP

Go to “configuration properties > general” and switch the “Platform toolset” to “Visual Studio 2012 – Windows XP (v110_xp)”.

 

2. Making it run on older systems

This caused me hours of work. By default VS2012 will “optimize” fp-operations. But it doesn’t work on all systems. Don’t know if it’s the older processors but I had at least 2 customers where a simple statement as “myfpvar=1″ caused the program to terminate without error message. To fix this go to “C++> Code generation” and set “Enable enhanced instruction set” to “No Enhanced Instructions (/arch:IA32)”.

“It still doesn’t work”

December 12th, 2012

In the past 48 hours I had the same strange effect twice (different products / problems). I wrote the customer three simple (yes, simple! Really!) steps to fix the problem. The answer was in both cases: “It still doesn’t work”.

In the end it turned out it both cases that the customer had not done these simple steps or not done them properly or whatever.

For me this means that I should work even even more with log files, configuration files and other “hard evidence”. And less with what the customer says…

 

 

Weird TextOut Unicode problems

October 26th, 2012

After porting Easy2Sync for Files to Unicode I experienced some really weird problems with some foreign characters. Unicode in general worked, Japanese characters were displayed nicely (not that I could read them). But Cyrillic characters failed when printed with TextOut and were displayed as small black rectangles.

Even weirder: Adding just 1 Japanese character to a string with Cyrillic characters caused the entire string to be printed right.

It seems that TextOut is only 50% Unicode compatible (of course Microsoft doesn’t mention this). So one has to use DrawText instead, which doesn’t seem to have these limitations. Since DrawText behaves differently regarding the position and background drawing, here’s a wrapper which fixes this and makes it behave like ExtTextOut:

void FixedExtTextOut (CDC *pDC, int x, int y, UINT nOptions, LPCRECT lpRect, LPCTSTR lpszString, UINT nCount, LPINT lpDxWidths)
{
 CRect rr(x, y, lpRect->right, lpRect->bottom);

 pDC->FillSolidRect(lpRect, pDC->GetBkColor());
 pDC->DrawText(lpszString, nCount, &rr, 0);
}

You’re not gonna catch this…

June 14th, 2012

You're not gonna catch this... (LIttle League baseball, May 2009 - 03 by Ed Yourdon; CC BY-SA 2.0)

C++ exceptions can be surprising. This works easily:

try
{
throw(1);
}
catch(…) //Catch all
{
//caught
}

But if you replace “throw(1);” with “throw;”, it suddenly doesn’t work anymore. Code compiles, exception is thrown, but it’s not caught. The program is terminated

MFC: Redirecting OnMouseWheel messages to the window under cursor

June 6th, 2012

By default MFC applies the MouseWheel message to the window that has the focus. Even though most users expect it to apply to the window under the cursor. (And even Microsoft’s style guide recommends that.)

To fix this, override the program’s PreTranslateMessage  function and add this:

 if (pMsg->message==WM_MOUSEWHEEL)
 {
    CPoint point;
    GetCursorPos (&point);

    HWND hWnd = ::WindowFromPoint (point);

    if (hWnd && pMsg->hwnd!=hWnd)
    {
       ::PostMessage(hWnd, pMsg->message, pMsg->wParam, pMsg->lParam);
       return(true);
    }
 }

Please note that you have to add this  before calling the default implementation of PreTranslateMessage.