Exemplo n.º 1
0
void MCControl::DoSetHScroll(MCExecContext& ctxt, int4 tx, integer_t scroll)
{
	if (opened)
	{
		if (hscroll(scroll - tx, True) == ES_ERROR)
			ctxt . Throw();
		resetscrollbars(True);
	}
}
Exemplo n.º 2
0
BOOL areaDoScroll(uiArea *a, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
{
	switch (uMsg) {
	case WM_HSCROLL:
		hscroll(a, wParam, lParam);
		*lResult = 0;
		return TRUE;
	case WM_MOUSEHWHEEL:
		hwheelscroll(a, wParam, lParam);
		*lResult = 0;
		return TRUE;
	case WM_VSCROLL:
		vscroll(a, wParam, lParam);
		*lResult = 0;
		return TRUE;
	case WM_MOUSEWHEEL:
		vwheelscroll(a, wParam, lParam);
		*lResult = 0;
		return TRUE;
	}
	return FALSE;
}
Exemplo n.º 3
0
Arquivo: ansi.c Projeto: AVLeo/libav
/**
 * Draw character to screen
 */
static void draw_char(AVCodecContext *avctx, int c)
{
    AnsiContext *s = avctx->priv_data;
    int fg = s->fg;
    int bg = s->bg;

    if ((s->attributes & ATTR_BOLD))
        fg += 8;
    if ((s->attributes & ATTR_BLINK))
        bg += 8;
    if ((s->attributes & ATTR_REVERSE))
        FFSWAP(int, fg, bg);
    if ((s->attributes & ATTR_CONCEALED))
        fg = bg;
    ff_draw_pc_font(s->frame->data[0] + s->y * s->frame->linesize[0] + s->x,
                    s->frame->linesize[0], s->font, s->font_height, c, fg, bg);
    s->x += FONT_WIDTH;
    if (s->x >= avctx->width) {
        s->x = 0;
        hscroll(avctx);
    }
}
Exemplo n.º 4
0
void MCControl::DoSetHScrollbar(MCExecContext& ctxt, MCScrollbar*& hsb, uint2& sbw)
{
	if (flags & F_HSCROLLBAR)
	{
		hsb = new (nothrow) MCScrollbar(*MCtemplatescrollbar);
		hsb->setparent(this);
		hsb->setflag(False, F_TRAVERSAL_ON);
		hsb->setflag(flags & F_3D, F_3D);
		hsb->setflag(flags & F_DISABLED, F_DISABLED);
		if (opened)
		{
			// MW-2010-12-10: [[ Out-of-bound Scroll ]] Make sure we reset the scroll to be in
			//   bounds when we display the scrollbar.
			hscroll(0, True);
			
			hsb->open();
			MCRectangle trect = hsb->getrect();
			sbw = trect . height;
			trect.width = trect . height + 1; // make sure SB is horizontal
			hsb->setrect(trect);
			setsbrects();
		}
		hsb->allowmessages(False);
	}
	else
	{
		delete hsb;
		hsb = NULL;
		if (opened)
			setsbrects();
	}

	// MW-2011-09-21: [[ Layers ]] Changing the property affects the
	//   object's adorned status.
	m_layer_attr_changed = true;
}
Exemplo n.º 5
0
Arquivo: ansi.c Projeto: AVLeo/libav
static int decode_frame(AVCodecContext *avctx,
                            void *data, int *got_frame,
                            AVPacket *avpkt)
{
    AnsiContext *s = avctx->priv_data;
    uint8_t *buf = avpkt->data;
    int buf_size = avpkt->size;
    const uint8_t *buf_end   = buf+buf_size;
    int ret, i, count;

    ret = ff_reget_buffer(avctx, s->frame);
    if (ret < 0){
        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
        return ret;
    }
    if (!avctx->frame_number) {
        memset(s->frame->data[0], 0, avctx->height * FFABS(s->frame->linesize[0]));
        memset(s->frame->data[1], 0, AVPALETTE_SIZE);
    }

    s->frame->pict_type           = AV_PICTURE_TYPE_I;
    s->frame->palette_has_changed = 1;
    memcpy(s->frame->data[1], ff_cga_palette, 16 * 4);

    while(buf < buf_end) {
        switch(s->state) {
        case STATE_NORMAL:
            switch (buf[0]) {
            case 0x00: //NUL
            case 0x07: //BEL
            case 0x1A: //SUB
                /* ignore */
                break;
            case 0x08: //BS
                s->x = FFMAX(s->x - 1, 0);
                break;
            case 0x09: //HT
                i = s->x / FONT_WIDTH;
                count = ((i + 8) & ~7) - i;
                for (i = 0; i < count; i++)
                    draw_char(avctx, ' ');
                break;
            case 0x0A: //LF
                hscroll(avctx);
            case 0x0D: //CR
                s->x = 0;
                break;
            case 0x0C: //FF
                erase_screen(avctx);
                break;
            case 0x1B: //ESC
                s->state = STATE_ESCAPE;
                break;
            default:
                draw_char(avctx, buf[0]);
            }
            break;
        case STATE_ESCAPE:
            if (buf[0] == '[') {
                s->state   = STATE_CODE;
                s->nb_args = 0;
                s->args[0] = 0;
            } else {
                s->state = STATE_NORMAL;
                draw_char(avctx, 0x1B);
                continue;
            }
            break;
        case STATE_CODE:
            switch(buf[0]) {
            case '0': case '1': case '2': case '3': case '4':
            case '5': case '6': case '7': case '8': case '9':
                if (s->nb_args < MAX_NB_ARGS)
                    s->args[s->nb_args] = s->args[s->nb_args] * 10 + buf[0] - '0';
                break;
            case ';':
                s->nb_args++;
                if (s->nb_args < MAX_NB_ARGS)
                    s->args[s->nb_args] = 0;
                break;
            case 'M':
                s->state = STATE_MUSIC_PREAMBLE;
                break;
            case '=': case '?':
                /* ignore */
                break;
            default:
                if (s->nb_args > MAX_NB_ARGS)
                    av_log(avctx, AV_LOG_WARNING, "args overflow (%i)\n", s->nb_args);
                if (s->nb_args < MAX_NB_ARGS && s->args[s->nb_args])
                    s->nb_args++;
                if ((ret = execute_code(avctx, buf[0])) < 0)
                    return ret;
                s->state = STATE_NORMAL;
            }
            break;
        case STATE_MUSIC_PREAMBLE:
            if (buf[0] == 0x0E || buf[0] == 0x1B)
                s->state = STATE_NORMAL;
            /* ignore music data */
            break;
        }
        buf++;
    }

    *got_frame = 1;
    if ((ret = av_frame_ref(data, s->frame)) < 0)
        return ret;
    return buf_size;
}
Exemplo n.º 6
0
LRESULT CALLBACK EditProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){

    char bstr[MAX_PATH];
    char *p,c;
    int i,k,n,o,r,f;
    POINT pt;
    struct edvars *ev;

    r = 0;

    //if (domove(GetParent(hwnd),message,wParam,lParam)) return 0;

    switch (message) {
    case WM_COPYDATA:
        if (0x4F4E4242 == ((PCOPYDATASTRUCT)lParam)->dwData)
        {
            char buff[MAX_PATH];
            int line_nr;
            const char *file = (const char*)((PCOPYDATASTRUCT)lParam)->lpData;
            getfile(buff, file, &line_nr);
            set_currentdir(buff);
            LoadFile(buff);
            if (line_nr) {
                ed_cmd(EK_GOTOLINE,line_nr-1);
                //ed_cmd(EK_MARK,lpos,imin(lpos+1,nextline(lpos,1)));
            }

            r = TRUE;
            goto p0r;
        }

        return bbn_receive_data(hwnd, lParam);

    default:
        if (bb_broadcast_msg == message && message)
        {
            if (bb_register(hwnd) && bb_getstyle(hwnd))
               goto reconfig1;
            return 0;
        }
        break;

    case BB_RECONFIGURE:
        if (bb_getstyle(hwnd))
            goto reconfig1;
        return 0;


    reconfig1:
        bb_close_dlg();
        makedlgfont();

    reconfig:
        zy0 = title_h + FRM-1;
        setsize(hwnd);
        new_back();
        InvalidateRect(hwnd, NULL, FALSE);
        return 0;

    case BB_SETSTYLESTRUCT:
    {
        StyleStruct *d = (StyleStruct *)wParam;
        StyleStruct *s = (StyleStruct *)lParam;
        memset(d, 0, sizeof *d);
        memcpy(d, s, sizeof *d);
        break;
    }

    case BB_SETSTYLE:
    {
        char *d = (char *)wParam;
        char *s = (char *)lParam;
        strcpy(d, s);
        break;
    }

    case WM_CREATE:
        zy0 = title_h + FRM-1;
        setsize(ewnd=hwnd);
        dragC  = LoadCursor(hInst,MAKEINTRESOURCE(101));
        dragCp = LoadCursor(hInst,MAKEINTRESOURCE(102));
        pointC = hCurs = LoadCursor(NULL,IDC_ARROW);
        init_edit(hwnd);
        DragAcceptFiles(hwnd,TRUE);
        if (false == bb_register(hwnd) || false == bb_getstyle(hwnd))
            readstyle(defstyle);
        goto reconfig1;


    case WM_DROPFILES: {
        POINT pt;
        HDROP hDrop = (HDROP)wParam; int n,f;
        ev=edp;
        f=0;

        GetCursorPos(&pt);
        if (GetAsyncKeyState(VK_CONTROL)<0) f=1;
        if (GetAsyncKeyState(VK_SHIFT)<0)   f=2;
        if (f) ScreenToClient(hwnd,&pt);

        for (i=-1, k=0; i<k; i++)
        {
            n=DragQueryFile (hDrop, i, p=bstr, 255);
            if (i<0)
            {
                k=n;
            }
            else
            if (f==0)
            {
                LoadFile(p);
            }
            else
            if (f==2)
            {
                if (readstyle(p))
                {
                    CopyFile(p, defstyle, FALSE);
                }
                break;
            }
            else
            {
                if (i == 0 && -1 == getmoupos(pt.x ,pt.y))
                    break;

                ed_cmd(EK_SETVAR);
                ed_cmd(EK_INSERT, p);
                ed_cmd(KEY_RET);
            }
        }
        DragFinish(hDrop);
        SetForegroundWindow(hwnd);
        if (f==0) goto showf;
        if (f==2) goto reconfig1;
        goto p0;
        }

    case WM_QUERYENDSESSION:
        return (1 == QueryDiscard(hwnd,1));

    case WM_ENDSESSION:
    {
        //void savecfg(void); savecfg();
        return 0;
    }

    case WM_DESTROY:
        exit_edit();
        DragAcceptFiles(hwnd,FALSE);
        bb_unregister(hwnd);
        PostQuitMessage(0);
        return 0 ;


    case WM_ACTIVATE:
        i=LOWORD(wParam);
        if (i==WA_ACTIVE)
            clickflag=0;

        return 0;

    case WM_ACTIVATEAPP:
        if (wParam) {
            clickflag=2;
        }
        return 0;

    case WM_LBUTTONDOWN:
    case WM_RBUTTONDOWN:
        if (alt_f) alt_f=2;

    case WM_MOUSEMOVE:
#if 0
    {
        static int wm;
        i = (short)HIWORD(lParam)/2;
        n = wm;
        wm = i;
        wParam = MAKELPARAM(0,(n-i)*30);
        goto mwhl;

    }
#endif
    case WM_LBUTTONDBLCLK:
    case WM_LBUTTONUP:
    case WM_RBUTTONUP:
    case WM_MBUTTONUP:
    case WM_MBUTTONDOWN:

        if (drag==0 && domove (hwnd, message, wParam, lParam))
            return 0;

        do_mouse(hwnd, wParam, lParam, message);

        if (message==WM_MOUSEMOVE && 0==(wParam & (MK_LBUTTON | MK_RBUTTON)))
            return 0;

        goto p0;

    case WM_TIMER:

        if (wParam==2) {
            resetmsg(hwnd);
            goto p0;
        }

        if (wParam==4) {
            mousewheelaccu=0;
        t0:
            KillTimer(hwnd, wParam);
            return 0;
        }

        GetCursorPos(&pt);
        ScreenToClient(hwnd,&pt);
        o=getmoupos(pt.x ,pt.y);
        if (o!=tcmd) {
            settimer(hwnd, o, SCROLL_INTERVAL);
            return 0;
        }

        if (tcmd==0) goto t0;
        c=ltup; ltup=0;
        ed_cmd(tcmd);
        ed_cmd(tcmd);
        upd=1;
        ltup=c;
        k=GetAsyncKeyState(VK_SHIFT)&0x8000;
        domarking(k!=0 || (0==moumrk && 0==drag));
        goto p0;


    case WM_SIZE:
        if (SIZE_MINIMIZED == wParam)
            return 0;

        if (edp) upd=1;
        ed_cmd(EK_SIZE);
        new_back();

    case WM_MOVE:
        setsize(hwnd);
        goto p0;

/*
   case WM_WINDOWPOSCHANGED:
        ewx0 = ((LPWINDOWPOS) lParam)->x;
        ewy0 = ((LPWINDOWPOS) lParam)->y;
        ewxl = ((LPWINDOWPOS) lParam)->cx;
        ewyl = ((LPWINDOWPOS) lParam)->cy;
        cfg_f |= 1;
        break; //process wm_move/wm_size

    case WM_WINDOWPOSCHANGING:
        SnapWindowToEdge((WINDOWPOS*)lParam, 10, 0);
        setsize(hwnd);
        return 0;
*/

    case WM_VSCROLL:
        vscroll(wParam);
        goto p0;

    case WM_HSCROLL:
        hscroll(wParam);
        goto p0;

    case WM_SETFOCUS:
        k_alt = 0>GetAsyncKeyState(VK_MENU);
        k_shft= 0>GetAsyncKeyState(VK_SHIFT);
        k_ctrl= 0>GetAsyncKeyState(VK_CONTROL);
        CreateCaret(hwnd,NULL,My_CaretSize,zy);
        caret=1;
        checkftime(hwnd);
        goto f1;

    case WM_KILLFOCUS:
        DestroyCaret();
        caret=0;
    f1:
        if (edp) upd=1;
        goto p0;

p0:
        r=0;
p0r:
        set_update(hwnd);
        return r;


    case WM_ERASEBKGND:
        return 1;

    case WM_PAINT:
        paint_window (hwnd);
        return 0;


    case WM_COMMAND:
        switch (LOWORD(wParam)) {

        case CMD_HELP:
#if 0
            bbnote_help();
            return 0;
#else
            if (fileexist(set_my_path(bstr, "bbnote.txt")))
                LoadFile(bstr);
            else if (fileexist(set_my_path(bstr, "docs/bbnote.txt")))
                LoadFile(bstr);
            goto p0;
#endif


        case CMD_EXIT:
            goto quit;

        case CMD_MENU_2:
        filemenu:
            if (ed0)
            {
                struct edvars *e = ed0;
                struct strl   *s = NULL;
                while (e)
                {
                    char temp[MAX_PATH];
                    sprintf(temp, "&%s", fname(e->sfilename));
                    appendstr(&s, temp);
                    e = e->next;
                }
                bb_file_menu (hwnd, lParam, s);
            }
            return 0;

        case CMD_MENU_1:
            bb_menu(hwnd, lParam);
            return 0;

        case CMD_COLOR:
            goto reconfig;

        case CMD_UPD:
            settitle();
            if (edp) upd=1;
            goto p0;


        case CMD_ZOOM:
    zoom:
            ShowWindow(hwnd, IsZoomed(hwnd) ? SW_SHOWNORMAL : SW_MAXIMIZE);
            return 0;

        case CMD_SEARCH:
        search:
            if (edp) bb_search_dialog(hwnd);
            return 0;

        case CMD_CLOSE:
        closefile:
            if (edp)
            {
                if (1 != QueryDiscard_1(hwnd, 1)) goto p0;
                if (ed0->next==NULL)
                {
                    extern HWND mwnd;
                    SendMessage(mwnd, WM_KEYDOWN, VK_ESCAPE, 0);
                    //DestroyWindow(mwnd);
                }
                CloseFile();
            }
            goto p0;

        case CMD_OPEN:
        openfile:
            ev=edp;
            DoFileOpenSave(hwnd, 0);
showf:
            if (ev==NULL || ev->next)
            {
                edp = ev ? ev->next : ed0;
                settitle();
            }
            goto p0;

        case CMD_RELOAD:
        reload:
            if (edp) f_reload(1);
            goto p0;


        case CMD_LIST:
            lParam = 2;
            goto filemenu;

        case CMD_NEW:
        newfile:
            NewFile();
            goto p0;

        case CMD_SAVE:
        savefile:
            if (edp) DoFileOpenSave(hwnd, 2);
            goto p0;

        case CMD_SAVEAS:
            if (edp!=NULL) DoFileOpenSave(hwnd, 1);
            break;

        case CMD_SAVEALL:
        //saveall:
            return QueryDiscard(hwnd, 0);

        case CMD_UNDO:
            ed_cmd(KEY_C_Z);
            goto p0;

        case CMD_REDO:
            ed_cmd(KEY_CS_Z);
            goto p0;

        case CMD_ABOUT:
            oyncan_msgbox(
              VERSION_STRING
              "\n"
              "\nediting with style"
              "\n04/2003 by grischka"
              "\n"
              "\[email protected]"
              , NULL, 1);
              return 0;


        case CMD_OPTIONS:
            goto config;

        case CMD_INFO:
            resetmsg(hwnd);
            p=(char*)lParam;
            if (p[0]==1) p++;
            else infoflg=1,infotimer=SetTimer(hwnd,2,666,NULL);
            strcpy(infomsg,p);
            if (edp) upd=1;
            goto p0;


        case CMD_FILECHG:
        {
            struct edvars *p=edp;
            edp=(struct edvars*)lParam;
            settitle();
            set_update(hwnd);
            f_reload(0);
            edp=p;
            settitle();
            goto p0;
        }

        default:
            i = LOWORD(wParam);
            if (i>=CMD_FILE && i< CMD_FILE_M)
            {
                struct edvars *p=ed0;
                i-=CMD_FILE;
                for (;i && p!=NULL; p=p->next,i--);
                if (p) {
                    //edp = p; settitle();
                    insfile(p);
                    goto p0;
                }
                return 0;
            }
            break;

        }
        break;

quit:
    if (1 == QueryDiscard(hwnd, 1))
        DestroyWindow(hwnd);
    return 0;

    case WM_SYSKEYDOWN:
        f=3; goto k1;

    case WM_SYSKEYUP:
        f=2; goto k1;

    case WM_KEYUP:
        if (wParam==VK_CONTROL && drag==3)  setdragc(2);
        f=0; goto k1;

    case WM_KEYDOWN:
        if (wParam==VK_CONTROL && drag==2)  setdragc(3);
        if (wParam==VK_SCROLL) { scroll_lock^=1; goto p0; }

        f=1; k1:

        n=LOWORD(wParam);

#if 0
        sprintf(bstr,"key %d  stat %d",n,f);
        if (n!=VK_MENU) MessageBox(NULL, bstr, "", MB_OK|MB_TOPMOST|MB_SETFOREGROUND);
#endif
        n=trans_keys(n, f);
        //if (0==n) goto p0;
        if (0==n) return 0;

        if (n>=2110 && n<=2117) {
        vmark=k_alt!=0;
        domarking(1);
        ed_cmd(n-100);
        domarking(1);
        goto p0;
        }

        switch (n) {

        case KEY_F8: return 0;
        case KEY_A_RIGHT:
        case KEY_F6:   nextfile(); goto p0;
        case KEY_A_LEFT:
        case KEY_C_F6: prevfile(); goto p0;

        case KEY_F10:  goto zoom;
        case KEY_F3:
        case KEY_C_F:  goto search;
        case KEY_C_F4: goto closefile;
        case KEY_C_O:  goto openfile;
        //case KEY_A_F3: goto reload;
        case KEY_C_N:  goto newfile;
        case KEY_C_L:  lParam = 0; goto filemenu;

        case KEY_F4:
            QueryDiscard(hwnd, 0);
            bb_reconfig();
            return 0;

        case KEY_S_F4:
            if (IDOK == oyncan_msgbox("Do you want to write all files?", "", 1+8))
                QueryDiscard(hwnd, 4);
            return 0;


        case KEY_C_S:  goto savefile;
        case KEY_A_F4: goto quit;

        case KEY_A_F2:
config:
            n = tabs;
            bb_config_dialog(hwnd);
            if (n!=tabs) goto reload;
            return 0;

        case KEY_ESC:
            if (drag==0) goto quit;
            dragmove=0;
            do_mouse(hwnd, 0,0,WM_LBUTTONUP);
            goto p0;

        case KEY_UP:
        case KEY_DOWN:
            if (scroll_lock) n+=200;
            goto defkey;

        case KEY_LEFT:
        case KEY_RIGHT:
            if (scroll_lock) n=(n^1)+204;
            goto defkey;
        }

    defkey:
        domarking(0);
        ed_cmd(n);
        i=n;
        if (i!=KEY_C_A
         && i!=KEY_C_U
         && i!=KEY_C_7
         && i!=KEY_C_8
         && i!=KEY_C_9
         && i!=KEY_C_0
         && i!=KEY_TAB
         && i!=KEY_S_TAB
         )
            unmark();
        goto p0;


    case WM_MOUSEWHEEL:
        i = mousewheelaccu + mousewheelfac * (short)HIWORD(wParam);
        while (i < -300)
            ed_cmd(KEY_C_DOWN), i+=600;
        while (i >  300)
            ed_cmd(KEY_C_UP),   i-=600;

        mousewheelaccu=i;
        unmark();
        SetTimer(hwnd, 4, 200, NULL);
        goto p0;


    case WM_NCPAINT:
        return 0;


    case WM_CHAR:
        n = LOWORD(wParam);
        if (n<32||n==127) return 0;

        resetmsg(hwnd);
        ed_cmd(EK_CHAR, n);
        goto p0;



    case CMD_GOTOLINE:
        ed_cmd(EK_GOTOLINE,wParam-1);
        ed_cmd(EK_MARK,lpos,imin(lpos+1,nextline(lpos,1)));
        lmf=2;
        goto p0;

    case CMD_LOADFILE:
        r=LoadFile((char*)wParam);
        goto p0r;

    case CMD_NSEARCH:
        resetmsg(hwnd);
        if (wParam&8) {
            ed_cmd(EK_REPLACE,(char *)lParam);
            if (wParam&1)
               ed_cmd(EK_GOTO,fpos+strlen((char*)lParam));
            goto p0;
        }
        unmark();
        if (wParam!=0) {
            struct sea *s=(struct sea *)lParam;
            struct edvars *ev0;

            for (ev0=edp;;) {
                r=ed_search(s);
                if (r || 0==(s->sf&128)) break;
                s->sf &= ~4;
                if (s->sf & 1) {
                    if (edp->next==NULL) break;
                    nextfile();
                    s->from=0;
                    continue;
                }
                if (s->sf & 2) {
                    if (edp==ed0) break;
                    prevfile();
                    s->from=flen;
                    continue;
                }}
            if (r<=0) {
                edp=ev0;
                settitle();
            } else {
               ed_cmd(KEY_HOME);
               ed_cmd(EK_MARK,s->a,s->e);
               ed_cmd(EK_GOTO,s->a);
            }
        }
        goto p0r;

    }
    return DefWindowProc (hwnd, message, wParam, lParam) ;
}
Exemplo n.º 7
0
Arquivo: main.c Projeto: yhcflyy/ui
static LRESULT CALLBACK tableWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	struct table *t;
	HDC dc;
	PAINTSTRUCT ps;
	NMHDR *nmhdr = (NMHDR *) lParam;
	NMHEADERW *nm = (NMHEADERW *) lParam;

	t = (struct table *) GetWindowLongPtrW(hwnd, GWLP_USERDATA);
	if (t == NULL) {
		// we have to do things this way because creating the header control will fail mysteriously if we create it first thing
		// (which is fine; we can get the parent hInstance this way too)
		if (uMsg == WM_NCCREATE) {
			CREATESTRUCTW *cs = (CREATESTRUCTW *) lParam;

			t = (struct table *) malloc(sizeof (struct table));
			if (t == NULL)
				abort();
			ZeroMemory(t, sizeof (struct table));
			t->hwnd = hwnd;
			// TODO this should be a global
			t->defaultFont = (HFONT) GetStockObject(SYSTEM_FONT);
			if (t->defaultFont == NULL)
				abort();
			t->font = t->defaultFont;
t->selected = 5;t->count=100;//TODO
			t->header = CreateWindowExW(0,
				WC_HEADERW, L"",
				// TODO is HOTTRACK needed?
				WS_CHILD | HDS_FULLDRAG | HDS_HORZ | HDS_HOTTRACK,
				0, 0, 0, 0,
				t->hwnd, (HMENU) 100, cs->hInstance, NULL);
			if (t->header == NULL)
				abort();
{t->imagelist = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32, 1, 1);
if(t->imagelist==NULL)abort();
{
HICON icon;
int unused;
icon = LoadIconW(NULL, IDI_ERROR);
if(icon == NULL)abort();
if (ImageList_AddIcon(t->imagelist, icon) == -1)abort();
if (ImageList_GetIconSize(t->imagelist, &unused, &(t->imagelistHeight)) == 0)abort();
}
}
			t->checkboxes = makeCheckboxImageList(t->hwnd, &(t->theme), &(t->checkboxWidth), &(t->checkboxHeight));
			t->focusedColumn = -1;
			SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR) t);
		}
		// even if we did the above, fall through
		return DefWindowProcW(hwnd, uMsg, wParam, lParam);
	}
	switch (uMsg) {
	case WM_PAINT:
		dc = BeginPaint(hwnd, &ps);
		if (dc == NULL)
			abort();
		drawItems(t, dc, ps.rcPaint);
		EndPaint(hwnd, &ps);
		return 0;
	case WM_SETFONT:
		t->font = (HFONT) wParam;
		if (t->font == NULL)
			t->font = t->defaultFont;
		// also set the header font
		SendMessageW(t->header, WM_SETFONT, wParam, lParam);
		if (LOWORD(lParam) != FALSE) {
			// the scrollbar page size will change so redraw that too
			// also recalculate the header height
			// TODO do that when this is FALSE too somehow
			resize(t);
			redrawAll(t);
		}
		return 0;
	case WM_GETFONT:
		return (LRESULT) t->font;
	case WM_VSCROLL:
		vscroll(t, wParam);
		return 0;
	case WM_MOUSEWHEEL:
		wheelscroll(t, wParam);
		return 0;
	case WM_HSCROLL:
		hscroll(t, wParam);
		return 0;
	case WM_SIZE:
		resize(t);
		return 0;
	case WM_LBUTTONDOWN:
		selectItem(t, wParam, lParam);
		return 0;
	case WM_SETFOCUS:
	case WM_KILLFOCUS:
		// all we need to do here is redraw the highlight
		// TODO ensure giving focus works right
		redrawRow(t, t->selected);
		return 0;
	case WM_KEYDOWN:
		keySelect(t, wParam, lParam);
		return 0;
	// TODO header double-click
	case WM_NOTIFY:
		if (nmhdr->hwndFrom == t->header)
			switch (nmhdr->code) {
			// I could use HDN_TRACK but wine doesn't emit that
			case HDN_ITEMCHANGING:
			case HDN_ITEMCHANGED:		// TODO needed?
				recomputeHScroll(t);
				redrawAll(t);
				return FALSE;
			}
		return DefWindowProcW(hwnd, uMsg, wParam, lParam);
	// TODO others?
	case WM_WININICHANGE:
	case WM_SYSCOLORCHANGE:
	case WM_THEMECHANGED:
		if (ImageList_Destroy(t->checkboxes) == 0)
			abort();
		t->checkboxes = makeCheckboxImageList(t->hwnd, &(t->theme), &(t->checkboxWidth), &(t->checkboxHeight));
		resize(t);		// TODO needed?
		redrawAll(t);
		// now defer back to DefWindowProc() in case other things are needed
		// TODO needed?
		return DefWindowProcW(hwnd, uMsg, wParam, lParam);
	case tableAddColumn:
		addColumn(t, wParam, lParam);
		return 0;
	case WM_GETOBJECT:		// accessibility
/*
		if (((DWORD) lParam) == OBJID_CLIENT) {
			TODO *server;
			LRESULT lResult;

			// TODO create the server object
			lResult = LresultFromObject(IID_IAccessible, wParam, server);
			if (/* TODO failure *|/)
				abort();
			// TODO release object
			return lResult;
		}
*/
		return DefWindowProcW(hwnd, uMsg, wParam, lParam);
	default:
		return DefWindowProcW(hwnd, uMsg, wParam, lParam);
	}
	abort();
	return 0;		// unreached
}