Skip to content

Commit

Permalink
hotkey error now uses messagebox
Browse files Browse the repository at this point in the history
  • Loading branch information
henkman committed Feb 6, 2015
1 parent 027553e commit cb91e06
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions virgo.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,21 @@ typedef struct {
Trayicon trayicon;
} Virgo;

static void * stb__sbgrowf(void *arr, int increment, int itemsize)
static void *stb__sbgrowf(void *arr, int increment, int itemsize)
{
int dbl_cur = arr ? 2*stb__sbm(arr) : 0;
int min_needed = sb_count(arr) + increment;
int m = dbl_cur > min_needed ? dbl_cur : min_needed;
int *p = realloc(arr ? stb__sbraw(arr) : 0, itemsize * m + sizeof(int)*2);
if (p) {
if (!arr)
if(p) {
if(!arr) {
p[1] = 0;
}
p[0] = m;
return p+2;
} else {
exit(1);
return (void *) (2*sizeof(int));
return (void *)(2*sizeof(int));
}
}

Expand All @@ -60,7 +61,6 @@ static HICON trayicon_draw(Trayicon *t, char *text, int len)
HBITMAP hOldBitMap;
HDC hdcMem;
ICONINFO iconInfo = {TRUE, 0, 0, t->hBitmap, t->hBitmap};

hdcMem = CreateCompatibleDC(t->hdc);
SetBkColor(hdcMem, RGB(0x00, 0x00, 0x00));
hOldBitMap = (HBITMAP) SelectObject(hdcMem, t->hBitmap);
Expand Down Expand Up @@ -101,7 +101,7 @@ static void trayicon_init(Trayicon *t)
static void trayicon_set(Trayicon *t, int number)
{
char snumber[2];
if(number < 0 || number > 9) {
if(number<0 || number>9) {
return;
}
snumber[0] = number + '0';
Expand Down Expand Up @@ -177,7 +177,8 @@ static int is_valid_window(HWND hwnd)
static void register_hotkey(int id, int mod, int vk)
{
if(RegisterHotKey(NULL, id, mod, vk) == 0) {
fprintf(stderr, "could not register key\n");
MessageBox(NULL, "could not register hotkey", "error",
MB_ICONEXCLAMATION);
exit(1);
}
}
Expand Down Expand Up @@ -288,7 +289,7 @@ int main(int argc, char **argv)
if(msg.wParam%2 == 0) {
virgo_go_to_desk(&v, msg.wParam/2);
} else {
virgo_move_to_desk(&v, (msg.wParam-1) / 2);
virgo_move_to_desk(&v, (msg.wParam-1)/2);
}
}
virgo_deinit(&v);
Expand Down

0 comments on commit cb91e06

Please sign in to comment.