Hi all :)
After thinking and banged my head against the wall for hours, I ask a question like a true beginner in dotNet:
How do I resize an image that fit with the button?
I did this, but I'm sure it's wrong ...
try (destroydialog :: t) catch()
rollout t "Test button donet"
(
Global Sel_Bitmap
button bt "Load Image..."
dotNetControl dnc "system.windows.forms.button" width:128 height:128
on bt pressed do
(
--- set measure image to fit measure dotNetControl (I think wrong way)
Sel_Bitmap = selectbitmap()
Bitma = bitmap 128 128
local temp_new_bitmap_filename = (getDir #preview +"/Temp.bmp")
local new_bitmap = bitmap 128 128 filename:temp_new_bitmap_filename
nb = copy Sel_Bitmap new_bitmap
save new_bitmap
-- Copy the bitmap and pass it to dotNet
setClipboardBitmap new_bitmap
-- dotNet clipboard object.
local clipboardObj = dotNetClass "System.Windows.Forms.Clipboard"
-- Get the image from the clipboard into a dotNet image object.
local imgObj = clipboardObj.GetImage()
local thumb = dotNetObject "System.Drawing.Image" imgObj
dnc.image = thumb
close new_bitmap
free new_bitmap
deleteFile temp_new_bitmap_filename
clipboardObj = undefined
imgObj = undefined
gc light:true
)
--- barigazy Label Events
on dnc mouseup arg do
(
case arg.Button of
(
(arg.Button.Left): display Sel_Bitmap
)
)
)
createdialog t 200 200
Any help?
Thanks
By
Comments (5)
Comment policy
try (destroydialog :: t) catch()
rollout t "Test button donet"
(
fn defLbl dnLbl =
(
dnLbl.BackColor = dnLbl.BackColor.dimgray
dnLbl.TextAlign = dnLbl.TextAlign.MiddleCenter
dnLbl.Text = "load image"
dnLbl.BackgroundImageLayout = dnLbl.BackgroundImageLayout.Stretch
)
local Sel_Bitmap = undefined
button bt "No Image..." pos:[5,5] width:128 height:18
dotNetControl dnc "Label" pos:[5,30] width:128 height:128
on t open do defLbl dnc
on bt pressed do
(
if isKindOf (Sel_Bitmap = selectbitmap()) bitmap do
(
_BMP = (dotNetObject "System.Drawing.Bitmap" Sel_Bitmap.filename)
dnc.text = "" ; dnc.BackgroundImage = _BMP
)
)
on dnc mouseup arg do
(
case arg.Button of
(
(arg.Button.Left): display Sel_Bitmap
(arg.Button.Right): (Sel_Bitmap = dnc.BackgroundImage = undefined; dnc.text = "No Image")
)
)
)
createdialog t 138 300
thanks for the example. you can explain quickly? I have learned something, but not everything... :)
Thanks again
rome isnt built in one night sir....step by step, little by little. Everyone does.
Yeah fajar, you have right. Step by step :)
try (destroydialog :: t) catch()
rollout t "Test button donet"
(
fn defLbl dnLbl =
(
dnLbl.BackColor = dnLbl.BackColor.dimgray
dnLbl.TextAlign = dnLbl.TextAlign.MiddleCenter
dnLbl.Text = "load image"
dnLbl.BackgroundImageLayout = dnLbl.BackgroundImageLayout.Stretch
)
fn defRect w h = (dotNetObject "System.Drawing.RectangleF" 0 0 w h)
local Sel_Bitmap = undefined
button bt "No Image..." pos:[5,5] width:128 height:18
dotNetControl dnc "Label" pos:[5,30] width:128 height:128
on t open do defLbl dnc
on bt pressed do
(
if isKindOf (Sel_Bitmap = selectbitmap()) bitmap do
(
_BMP = (dotNetObject "System.Drawing.Bitmap" Sel_Bitmap.filename)
dnc.text = "" ; dnc.BackgroundImage = _BMP
)
)
on dnc mouseup arg do
(
case arg.Button of
(
(arg.Button.Left): display Sel_Bitmap
(arg.Button.Right): (Sel_Bitmap = dnc.BackgroundImage = undefined; dnc.text = "No Image")
)
)
)
createdialog t 138 300