来自中国的朋友,欢迎您在本版面使用中文讨论问题。请注意,如果您想得到不懂中文的人的帮助,请同时提供英文译文。
Help and discussions in Chinese.
by liqi98136 » Wed Mar 10, 2010 8:57 am
- Code: Select all
import "ecere"
class Form1 : Window
{
text = "移动图片";
background = black;
borderStyle = sizable;
hasMaximize = true;
hasMinimize = true;
hasClose = true;
size = { 800, 600 };
Bitmap bmp;
Point drag , moving;
bool dragging;
bool OnLoadGraphics(void)
{
bmp = Bitmap{};
bmp.LoadT(":back.jpg", null, displaySystem);
return true;
}
void OnUnloadGraphics(void)
{
bmp.Free();
bmp = null;
}
void OnRedraw(Surface surface)
{
surface.SetForeground(white);
surface.Blit(bmp, moving.x-drag.x,moving.y-drag.y, 0,0, bmp.width, bmp.height);
}
bool OnLeftButtonDown(int x, int y, Modifiers mods)
{
dragging = true;
drag.x = moving.x = x;
drag.y = moving.y = y;
Capture();
SetMouseRange( Box { 0, 0, this.size.w-1,this.size.h-1} );
return true;
}
bool OnLeftButtonUp(int x, int y, Modifiers mods)
{
ReleaseCapture();
FreeMouseRange();
dragging = false;
moving.x=x;
moving.y=y;
Update(null);
return true;
}
/*bool OnMoving(int * x, int * y, int w, int h)
{
drag.x=x;
drag.y=y;
Update(null);
return true;
}
bool OnCreate(void)
{
drag=moving={0,0};
Update(null);
return true;
}
*/
}
Form1 form1 {};
-
liqi98136
-
- Posts: 53
- Joined: Sun Jan 17, 2010 11:37 pm
Return to 欢迎使用中文讨论
Who is online
Users browsing this forum: No registered users and 1 guest