ADAM'S WEB PRESENCE

27 April 2006

Recycled Flotsam

Filed under: General — adam @ 12:16 pm

Well, it seems I was a little hasty pulling down some of my older material as a few people seem to have linked to it and it gets some traffic. So here are some popular older items:

Adam’s Old Stuff Page


20 April 2006

How to make an SDL window the child of another window in Win32

Filed under: Nerd Notes — adam @ 12:23 pm

This had me beating my head against the wall for days. Now as you know, It is fairly straightforward to open an SDL surface in a window:

SDL_Surface *screen = SDL_SetVideoMode(width, height, 24, SDL_NOFRAME);
if(screen == 0)
    throw AVException(SDL_GetError());

The SDL_NOFRAME option removes the window borders so the window is now ready to become a child window. Next we need to obtain the SDL window’s HWND

#include <SDL_syswm.h>

struct SDL_SysWMinfo wmInfo;
SDL_VERSION(&wmInfo.version);

if(-1 == SDL_GetWMInfo(&wmInfo))
    throw AVException(SDL_GetError());

HWND hwndSDL = wmInfo.window;

Now we can parent it to our window:

SetParent(hwndSDL, hwndMyWindow);

So far so good but this is where it all falls apart. When the parent window is moved, the SDL window does not move with it. You get an effect where the clipping rectangle moves but the contents of the window stay put.

This took me days to figure out. It tried messsing about with WM_MOVE handlers and using offsets on my SDL_UpdateRect() coordinates and all kinds of crazy stuff but in the end I found two important facts:

  1. The SDL window does not receive WM_MOVE noftifications from its parent
  2. Using MoveWindow to set the position of the SDL window does not work if the new coordinates are the same as the current coordinates (that was the tough one to work out)

Since I am using SDL to play video, I am constantly updating the window all the time. This means I can use a test in my update function to check if the window has moved. If so, I need to use two calls to MoveWindow to fool SDL into moving. If you are not doing animation, perhaps you could use a timer call or something to achieve the same result. Anyway, here is the code:

// Dumps the given frame to the screen.
void showFrame(SDL_Surface *surface)
{
    static RECT lastPos;

// Check to see if the window has been moved.
    RECT r;
    GetWindowRect(hwndSDL, &r);

    if(r.left != lastPos.left || r.top != lastPos.top)
    {
        GetClientRect(hwndSDL, &r);
        MoveWindow(hwndSDL, r.left, r.top, r.right - r.left, r.bottom - r.top, FALSE);
        MoveWindow(hwndSDL, r.left + 4, r.top, r.right - r.left, r.bottom - r.top, FALSE);
        lastPos = r;
    }

// Copy the off-screen surface to the screen.
    SDL_BlitSurface(surface, 0, screen, 0);
    SDL_UpdateRect(screen, 0, 0, 0, 0);
}

13 April 2006

Simple Slide Show v1.2 Released

Filed under: Products — adam @ 12:12 pm

This is a Windows application I wrote ages ago. I’ve given it a bit of a brush up and put it on my freeware page. It’s a really easy and simple slide show player you can use to distribute self-running slide shows.

Click Here to check it out.


10 April 2006

Spam Sucks

Filed under: General — adam @ 12:11 pm

The level of spam has been annoying me lately. About 80 - 90% of my inbox now consists of this glorious substance. When I have a little spare time and sufficient levels of anger to motivate me, I always like to engage in a little spammer poisoning. Here is what I like to do:

Any request to “verify my account details” (usually with PayPal or some bank I have not got an account with), I always click on the link and key in some false details. If enough people do this kind of thing, the spammers will be flooded with so much garbage, it will not be worth their while to continue this kind of scam. There is a brilliant website at http://www.darkcoding.net/index.php/credit-card-numbers/ which can generate legitimate-looking credit card numbers to enter into their forms.

Any marketing scheme to sell Viagra, rolexen or whatever else, I visit and if I feel really annoyed, see if I can order one using a fake card number, fake delivery address etc. The advertiser will have to pay for the click-through and they will become pissed off at the spammer for all the dodgy orders and non-sale click-throughs if enough people do this kind of thing.

Any spam that only has an email address and no website, I send them an email simply saying “You suck”.

If they only have a phone number, there is not much I can do since they are mostly U.S. phone numbers and it would cost too much for me to dial them but I encourage anyone who actually lives in the U.S.A. to dial them up and tell them that they suck (especially if it is a toll- free number).

Now I hear a lot of you saying that these techniques will just let them know I exist and thus attract more spam but I already get all the spam anyway I am sure so what have I got to lose by annoying these bastards as much as I can.


Powered by WordPress