pb资源文件的问题
用户自定义对象里的图片,如果使用pbr文件编译, 编译后拿到其他地方运行时无法显示图片。 而不是用户自定义对象里的就很正常。 文件路径绝对没有问题。 这个问题怎么解决啊
[解决办法]
可能你的用户自定义对象中,对于图片的使用,不像pb自带的控件那样,直接使用图片地址。而是使用api中类似loadimage等先读取图片dc句柄,再画到控件上的方法。
这个时候你可以在你的程序中打开一个popup类型的窗口w_loadimage,该窗口上放置一个picture控件p_1,窗口设置为可见,但是显示在屏幕之外(可以将窗口的x和y属性都设置为负数)。
在该窗口上添加一个函数wf_loadimage(string as_imagefile)
函数内容为:(其中的API函数自己添加,API变量自己声明)
- C/C++ code
//========================================================================================================================// 按照图片实际大小载入图片//========================================================================================================================ulong hdc, ll_rs = 0, hwnd, ll_memdc, ll_oldboolean lblong lw, lhlw = 0; lh = 0as_imagefile = trim( as_imagefile )if isnull( as_imagefile ) or as_imagefile = '' then return 0hwnd = handle( p_1 )//将图片显示到p_1控件中p_1.originalsize = truep_1.map3dcolors = falsep_1.picturename = as_imagefilelw = unitstopixels( p_1.width, xunitstopixels! )lh = unitstopixels( p_1.height, yunitstopixels! )hdc = GetDC( hwnd )ll_rs = CreateCompatibleBitmap( hdc, lw, lh )ll_memdc = CreateCompatibleDC( hdc )ReleaseDC( hwnd, hdc )ll_old = SelectObject( ll_memdc, ll_rs )//对控件p_1进行截图,将所截的图片保存到ll_rs中constant long WM_PAINT = 15Send( hwnd, WM_PAINT, ll_memdc, 0 )ll_rs = SelectObject( ll_memdc, ll_old )DeleteDC(ll_memdc)p_1.picturename = ''return ll_rs