Esempio n. 1
0
bool load_dll(void)
{
	if (NULL == hEngineInst)
	{
		char engine_path[MAX_PATH];
		const char *error = NULL;

		hEngineInst = LoadLibrary(set_my_path(engine_path, BBLEANSKIN_ENGINEDLL));
		*(FARPROC*)&EntryFunc = GetProcAddress(hEngineInst, "EntryFunc");

		if (NULL == EntryFunc)
			error = "Could not load: " BBLEANSKIN_ENGINEDLL;
		else
			if (ENGINE_THISVERSION != EntryFunc(ENGINE_GETVERSION, NULL))
				error = "Wrong version: " BBLEANSKIN_ENGINEDLL;

		if (error)
		{
			free_dll();
			MessageBox(NULL, error, szAppName,
					   MB_OK | MB_ICONERROR | MB_SETFOREGROUND | MB_TOPMOST);
			return false;
		}
	}
	return true;
}
Esempio n. 2
0
void _log_printf(int flag, const char *fmt, ...)
{
    static bool log_first;
    char log_path[MAX_PATH];
    FILE *fp;
    va_list arg;
    char date[32];
    char time[16];

    if (flag && 0 == (flag & Settings_LogFlag))
        return;

    fp = fopen(set_my_path(NULL, log_path, "blackbox.log"), "a");

    if (NULL == fp)
        return;

    if (false == log_first) {
        _strdate(date);
        _strtime(time);
        fprintf(fp, "\nStarting Log %s %s\n", date, time);
        log_first = true;
    }

    if ('\n' != *fmt) {
        _strtime(time);
        fprintf(fp, "%s  ", time);
    }

    va_start(arg, fmt);
    vfprintf(fp, fmt, arg);
    fprintf(fp, "\n");
    fclose(fp);
}
Esempio n. 3
0
void read_buttons(void)
{
	char path[MAX_PATH];
	HBITMAP hbmp = (HBITMAP)LoadImage(
					   NULL, set_my_path(path, "buttons.bmp"),
					   IMAGE_BITMAP,
					   0,
					   0,
					   LR_LOADFROMFILE// | LR_CREATEDIBSECTION
				   );

	if (NULL == hbmp)
	{
		static unsigned char default_buttons[6*2][BUTTON_MAP_SIZE] =
		{
			{ 0x00, 0x8C, 0xB9, 0xE3, 0x83, 0x83, 0x8F, 0x3B, 0x63, 0x00, 0x00 },
			{ 0x00, 0x8C, 0xB9, 0xE3, 0x83, 0x83, 0x8F, 0x3B, 0x63, 0x00, 0x00 },
			{ 0x00, 0xFC, 0xF9, 0x13, 0x24, 0x48, 0x90, 0x20, 0x7F, 0x00, 0x00 },
			{ 0xF8, 0xF1, 0x23, 0xFC, 0xF9, 0x33, 0x7C, 0x88, 0x10, 0x3F, 0x00 },
			{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3F, 0x7F, 0x00, 0x00 },
			{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3F, 0x7F, 0x00, 0x00 },
			{ 0x00, 0x1C, 0x38, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
			{ 0x00, 0x1C, 0x38, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
			{ 0x00, 0x20, 0xE0, 0xE0, 0xE3, 0x0F, 0x07, 0x0E, 0x1C, 0x00, 0x00 },
			{ 0x00, 0x70, 0xE0, 0xC0, 0xE1, 0x8F, 0x0F, 0x0E, 0x08, 0x00, 0x00 },
			{ 0x00, 0x0C, 0x18, 0x30, 0xE0, 0xC7, 0x80, 0x01, 0x03, 0x00, 0x00 },
			{ 0x00, 0xFC, 0xF9, 0xF3, 0x07, 0x01, 0x02, 0x04, 0x08, 0x00, 0x00 },
		};
		memcpy(&mSkin.button_bmp, default_buttons, sizeof default_buttons);
		return;
	}

	HDC hdc = CreateCompatibleDC(NULL);
	HGDIOBJ other = SelectObject(hdc, hbmp);
	struct button_bmp *bp = mSkin.button_bmp;
	int b, state, y, x, n;
	for (b = 0; b < 6; ++b, ++bp)
		for (state = 0; state < 2; ++state)
		{
			for (n = y = 0; y < BUTTON_SIZE; ++y)
				for (x = 0; x < BUTTON_SIZE; ++x, ++n)
				{
					COLORREF c = GetPixel(hdc, b*(1+BUTTON_SIZE)+1+x, state*(1+BUTTON_SIZE)+1+y);
					if (0 == c) bp->data[state][n/8] |= 1 << n%8;
				}
#if 0
			unsigned char *u = (unsigned char*)bp->data[state];
			dbg_printf("       { "
					   "0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X },",
					   u[0], u[1], u[2], u[3], u[4], u[5], u[6], u[7], u[8], u[9], u[10]);
#endif
		}
	DeleteObject(SelectObject(hdc, other));
	DeleteDC(hdc);
}
Esempio n. 4
0
int BBP_handle_broam(struct plugin_info *PI, const char *temp)
{
    int v;
    const char *s;

    if (BBP_broam_bool(PI, temp, "useSlit", &PI->useSlit))
    {
        BBP_set_window_modes(PI);
        return BBP_BROAM_HANDLED;
    }

    if (BBP_broam_bool(PI, temp, "pluginToggle", &PI->pluginToggle))
    {
        BBP_set_window_modes(PI);
        return BBP_BROAM_HANDLED;
    }
/*
    if (BBP_broam_bool(PI, temp, "visible", &PI->visible))
    {
        BBP_set_window_modes(PI);
        return BBP_BROAM_HANDLED;
    }
*/
    if (BBP_broam_bool(PI, temp, "alwaysOnTop", &PI->alwaysOnTop))
    {
        BBP_set_window_modes(PI);
        return BBP_BROAM_HANDLED;
    }

    if (BBP_broam_bool(PI, temp, "clickRaise", &PI->clickRaise))
    {
        BBP_set_window_modes(PI);
        return BBP_BROAM_HANDLED;
    }

    if (BBP_broam_bool(PI, temp, "AutoHide", &PI->autoHide))
    {
        BBP_set_window_modes(PI);
        return BBP_BROAM_HANDLED;
    }

	if (BBP_broam_bool(PI, temp, "transparent", &PI->transparent))
	{
		BBP_set_window_modes(PI);
		return BBP_BROAM_HANDLED;
	}

    if (BBP_broam_int(PI, temp, "snapWindow", &PI->snapWindow))
    {
        BBP_set_window_modes(PI);
        return BBP_BROAM_HANDLED;
    }

    if (BBP_broam_int(PI, temp, "icon.saturation", &PI->saturation))
    {
        BBP_set_window_modes(PI);
        return BBP_BROAM_HANDLED;
    }

    if (BBP_broam_int(PI, temp, "icon.hue", &PI->hue))
    {
        BBP_set_window_modes(PI);
        return BBP_BROAM_HANDLED;
    }

    if (BBP_broam_int(PI, temp, "alpha.value", &v))
    {
        PI->alphaValue = (BYTE)v;
        BBP_set_window_modes(PI);
        return BBP_BROAM_HANDLED;
    }

    if (BBP_broam_string(PI, temp, "placement", &s))
    {
        int n = get_string_index(s, placement_strings);
        if (-1 != n) {
            BBP_set_place(PI, n);
        }
        return BBP_BROAM_HANDLED;
    }

    if (!stricmp(temp, "about"))
    {
        PI->about_box(_THIS);
        return BBP_BROAM_HANDLED;
    }

    if (!stricmp(temp, "editRC"))
    {
        BBP_edit_file(PI->rcpath);
        return BBP_BROAM_HANDLED;
    }

    if (0 == stricmp(temp, "readme"))
    {
        char temp[MAX_PATH];
        BBP_edit_file(set_my_path(PI->hInstance, temp, "readme.txt"));
        return BBP_BROAM_HANDLED;
    }

    if (!stricmp(temp, "LoadDocs"))
    {
        char docspath[MAX_PATH];
		locate_file(PI->hInstance, docspath, PI->class_name, "html");
        BBExecute(NULL, "open", docspath, NULL, NULL, SW_SHOWNORMAL, false);
        return BBP_BROAM_HANDLED;
    }

    if (BBP_broam_string(PI, temp, "orientation", &s))
    {
        if (!stricmp(s, "vertical"))
            PI->orient_vertical = true;
        else
        if (!stricmp(s, "horizontal"))
            PI->orient_vertical = false;
        BBP_set_window_modes(PI);
        return BBP_BROAM_HANDLED | BBP_BROAM_METRICS;
    }

    return 0;
}
Esempio n. 5
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) ;
}
Esempio n. 6
0
HBITMAP load_desk_bitmap(const char* command, bool makebmp)
{
    char exe_path[MAX_PATH];
    char bmp_path[MAX_PATH];
    char buffer[4*MAX_PATH];
    int x, r;

    const char *cptr;
    unsigned long bsrt_vernum;

    cptr = command;
    if (false == is_bsetroot_command(&cptr)) {
bbexec:
        if (command[0])
            BBExecute_string(command, RUN_NOERRORS);
        return NULL;
    }

#ifndef BBTINY
    if (makebmp) {
        HBITMAP bmp = make_root_bmp(cptr);
        if (bmp)
            return bmp;
    }
#endif

    set_my_path(NULL, exe_path, "bsetroot.exe");
    bsrt_vernum = getfileversion(exe_path);
    //dbg_printf("bsrt_vernum %08x", bsrt_vernum);
    if (bsrt_vernum < 0x02000000)
        goto bbexec;

    x = sprintf(buffer, "\"%s\" %s", exe_path, cptr);

#ifndef BBTINY
    if (makebmp) {
        set_my_path(NULL, bmp_path, "$bsroot$.bmp");
        x += sprintf(buffer + x, " -save \"%s\"", bmp_path);
    }
#endif

#if 0
    if (bsrt_vernum >= 0x02010000) {
        char base_path[MAX_PATH];
        file_directory(base_path, bbrcPath(NULL));
        x += sprintf(buffer + x, " -prefix \"%s\"", base_path);
    }
#endif

    r = BBExecute_string(buffer, RUN_NOSUBST|RUN_WAIT|RUN_NOERRORS);
    //dbg_printf("command <%s>", buffer);
    if (0 == r)
        return NULL;

#ifndef BBTINY
    if (makebmp)
        return read_bitmap(bmp_path, true);
#endif

    return NULL;
}
Esempio n. 7
0
extern "C" BOOL WINAPI DllMain(HINSTANCE hi, DWORD reason, LPVOID reserved)
{
	if (reason==DLL_PROCESS_ATTACH)
	{
		hInstance = hi;
		WNDCLASS wc;
		RECT dt;

		if (BBhwnd)
		{
			MessageBox(BBhwnd, "Dont load me twice!", szAppName, MB_OK|MB_SETFOREGROUND);
			return FALSE;
		}

		const char *bbv = GetBBVersion();
		if (0 == memicmp(bbv, "bblean", 6)) BBVersion = 2;
		else
			if (0 == memicmp(bbv, "bb", 2)) BBVersion = 1;
			else BBVersion = 0;

		BBhwnd = GetBBWnd();
		set_my_path(rcpath, "bbLeanSkin.rc");

		ZeroMemory(&wc, sizeof(wc));
		wc.lpszClassName = szAppName;
		wc.hInstance = hInstance;
		wc.lpfnWndProc = WndProc;

		// ##### COMMENTED OUT DUE TO COMPATIBILITY REASONS #####
		// ###### -> WAS THIS CHECK USED TO DETECT BBLEAN? ######
		// if (NULL == GetSettingPtr(SN_WINUNFOCUS_TITLE))
		//	return FALSE;
		// ######################################################

		if (FindWindow(wc.lpszClassName, NULL) || FALSE == RegisterClass(&wc))
			return FALSE;

		// center the window
		SystemParametersInfo(SPI_GETWORKAREA, 0, &dt, 0);
		int width = 480;
		int height = 300;
		int xleft = (dt.left+dt.right-width)/2;
		int ytop = (dt.top+dt.bottom-height)/2;

		CreateWindow(
			wc.lpszClassName,
			"bbLeanSkin Log",
			//WS_OVERLAPPEDWINDOW,
			WS_POPUP|WS_CAPTION|WS_SIZEBOX|WS_SYSMENU|WS_MAXIMIZEBOX|WS_MINIMIZEBOX,
			xleft, ytop, width, height,
			NULL,
			NULL,
			wc.hInstance,
			NULL
		);
	}
	else
		if (reason==DLL_PROCESS_DETACH)
		{
			stopEngine();
			DestroyWindow(m_hwnd);
			UnregisterClass(szAppName, hInstance);
		}
	return TRUE;
}
Esempio n. 8
0
bool make_exclusion_list(void)
{
	struct elist
	{
		struct elist *next;
		int flen;
		int option;
		char buff[1];
	} *p0 = NULL, **pp = &p0, *p;

	int t_len   = 0;
	int t_count = 0;
	char exclusionspath[MAX_PATH];

	// first read all strings into a list and calculate the size...
	FILE *fp = FileOpen(set_my_path(exclusionspath, "exclusions.rc"));
	if (fp) for (;;)
		{
			char *line, line_buffer[256];
			if (false == ReadNextCommand(fp, line_buffer, sizeof line_buffer))
			{
				FileClose(fp);
				break;
			}
			strlwr(line = line_buffer);
			int option = 0;
			if (0 == memicmp (line, "hook-early:", 11))
			{
				option = 1;
				line += 10;
				while (' ' == *++line);
			}

			int line_len = strlen(line);

			char *cp = strchr(line, ':');
			if (cp) *cp++ = 0;
			else *(cp = line + line_len++) = 0;
			p = (struct elist *)malloc(line_len + sizeof(struct elist));
			memcpy(p->buff, line, ++line_len);
			p->flen = cp - line;
			p->option = option;
			*(pp = &(*pp = p)->next) = NULL;
			t_len += line_len-2;
			t_count++;
		}

	t_len += sizeof(struct exclusion_info) + (t_count-1) * sizeof(struct exclusion_item);

	// ... then create the shared mem, which is supposed to succeed,...
	if (FALSE == CreateSharedMem(offset_exInfo + t_len))
		return false;

	// ... and finally copy the list into it, free items by the way.
	struct exclusion_info *pExclInfo = &lpvMem->exInfo;
	pExclInfo->size = t_len;
	pExclInfo->count = t_count;
	struct exclusion_item *ei = pExclInfo->ei;
	while (p0)
	{
		p = p0;
		p0 = p0->next;
		char *cp = ei->buff;
		ei->flen = 1+strlen(strcpy(cp, p->buff));
		ei->clen = 1+strlen(strcpy(cp+ei->flen, p->buff+p->flen));
		ei->option = p->option;
		//dbg_printf("added \"%s:%s\"", p->buff, p->p_class);
		free(p);
		ei = (struct exclusion_item *)(ei->buff + ei->flen + ei->clen);
	}
	return true;
}