Jump to content
sjesper

Getting a picture of my bank into a form?

Recommended Posts

Hello there :-)

 

I'm currently working on my AutoHerblore and thought i would add potion support, but not just a regular one that needs to have all potions coded but one that open bank and take a picture and put every slot in some TImage boxes in my form and then let you choose all ur ingredients, so it's dynamic. I've been trying to that but all the boxes just turn black. Here is my code:

 

[sCAR]procedure SetImage(Sender: TObject);

var

i: Integer;

BitMap: Integer;

Canvas: TCanvas;

TB: TBox;

begin

for i := 0 to 39 do begin

GetBankSlotBounds(i);

Bitmap := BitmapFromString(44, 44, '');

Canvas := GetBitmapCanvas(Bitmap);

FastDrawClear(Bitmap, clBlack);

CopyCanvas(Canvas, Image.Canvas, 0, 0, 44, 44, 0, 0, 44, 44);

SafeCopyCanvas(GetClientCanvas, Image.Canvas, TB.X1, TB.Y1, TB.X2, TB.Y2, 0, 0, 44, 44);

end;

end;[/sCAR]

Edited by sjesper
Link to comment
Share on other sites

set the image to the background of a form then put buttons over the image and before you set it as a background you can break the bank into 49 slots but the problem is there ingredients wound need to be in the first bank Tab unless you get the tab for ea ingredient. The problem with this the person would have to log in to do this, and if it was a multiplayer script they would need to log in ea player. You cloud also dynamically make the buttons with a for loop. Or since you taking the same picture ea time (Size Wise) you could get the mouse position when the mouse is clicked then use a case statement to determine the slot that was clicked.

 

Another option would be to just have them press a button while the mouse is over top a slot and store it that way instead of using a form and bitmap.

Edited by shadowrecon
Link to comment
Share on other sites

set the image to the background of a form then put buttons over the image and before you set it as a background you can break the bank into 49 slots but the problem is there ingredients wound need to be in the first bank Tab unless you get the tab for ea ingredient. The problem with this the person would have to log in to do this, and if it was a multiplayer script they would need to log in ea player. You cloud also dynamically make the buttons with a for loop. Or since you taking the same picture ea time (Size Wise) you could get the mouse position when the mouse is clicked then use a case statement to determine the slot that was clicked.

 

Another option would be to just have them press a button while the mouse is over top a slot and store it that way instead of using a form and bitmap.

 

I have made the script so it runs, open the bank and then open up this not working form xP.

 

I'm also doing this for learning and make it looks awsome x-D. The smart thing about this is that it doesn't need any type in with how many ingredients there is needed and what slot they are at. The count of ingredients will be calculated, the slot selected and it will be very easy to use :-)

 

I don't need help with making the slot's be "selected" in the GUI i just can't get the bankslots in :-( And i'm not taking the same picture all the time, im taking one for each slots (I have made 39 TImage boxes :-D)

 

---------- Post added at 06:09 PM ---------- Previous post was at 04:59 PM ----------

 

Wow did i just spend 2 hours searching all over the internet for a solution and then found out that i forgot to make my TB to BankBounds but just returned them to nothing -.-''

Link to comment
Share on other sites

This is almost what your looking for. It may need alittle tweaking on the Row/Col X,Y numbers but i ran it trough a test and it gives the correct slot for which ever box is picked. Hope this helps you understand it a little better

[scar]

program New;

{$Define RS2}

{.include OSI\OSI.scar}

 

var

Form1: TForm;

Image1: TImage;

Slot: Integer;

 

Procedure SetupImage; // Retunrs picture of bank screen with Boxes around ea item

var

I,II,BMP,W,H: Integer;

Canvas,SCanvas: TCanvas;

TPA: TPointArray;

Begin

// Making the bitmap and filling in the boxes

BMP := BitmapFromString(MBPW,MBPH,'');

CopyClientToBitmap(BMP,MBX1,MBY1,MBX2-46,MBY2+10);

For I := 0 to 49 do

Begin

TPA := TBOutlineToTPA(Box(5 + ((I mod 10) * 44),5+((I div 10) * 44), 40 + ((I mod 10) * 44), 38 + ((I div 10) * 44)));

For II := 0 to High(TPA) do

FastSetPixel(BMP, TPA[iI].X, TPA[iI].Y, clRed);

end;

 

// Seting the bitmap as the form back ground

SCanvas := Image1.Canvas;

Canvas := GetBitmapCanvas(BMP);

GetBitmapSize(BMP, W, H);

SafeCopyCanvas(Canvas, SCanvas, 0, 0, W, H, 0, 0, W, H);

freeBitmap(BMP);

end;

 

Procedure SetupSlots(Sender: TObject);

Var

X,Y: Integer;

Row,Col: Integer;

HWDC: Integer;

Begin

 

HWDC := GetClientWindowHandle; // Store Client

SetClientWindowHandle(Form1.Handle);// SetForm as client

 

GetMousePos(X,Y);

 

X := X - 8; // These remove the border of the form

Y := Y - 30;

 

Writeln( 'X: '+InttoStr(X)+' Y: '+InttoStr(Y) );

 

Case Y of // Increments of 40

0..40: Row := 1;// First Row

41..82: Row := 2;// Second Row

83..124: Row := 3;

125..165: Row := 4;

166..214: Row := 5;

end;

 

Case X of // Increments of 40

0..40: Col := 1;// First Col

41..82: Col := 2;// Second Col

83..124: Col := 3;

125..165: Col := 4;

166..206: Col := 5;

207..247: Col := 6;

248..288: Col := 7;

289..328: Col := 8;

329..368: Col := 9;

369..444: Col := 10;

end;

 

Writeln( 'Row: '+InttoStr(Row)+' Col: '+InttoStr(Col) );

Slot := GetBankSlotIndex(Row,Col);

 

Writeln('Slot: '+InttoStr(Slot));

SetClientWindowHandle(HWDC);// Return to orginal Client

end;

 

procedure Form1_Init;

begin

Form1 := CreateForm;

Image1 := TImage.Create(Form1);

with Form1 do

begin

ClientHeight := MBPH+10;

ClientWidth := MBPW-46;

OldCreateOrder := False;

PixelsPerInch := 96;

end;

with Image1 do

begin

Parent := Form1;

OnClick :=@SetupSlots;

Left := 0;

Top := 0;

Width := MBPW-46;

Height := MBPH+10;

end;

 

SetupImage; // Setup image and displays it on form

 

end;

 

procedure Form1_SafeInit;

var

v: TVariantArray;

begin

SetLength(v, 0);

ThreadSafeCall('Form1_Init', v);

end;

 

function Form1_ShowModal: Boolean;

begin

Result := Form1.ShowModal = mrOk;

end;

 

function Form1_SafeShowModal: Boolean;

var

v: TVariantArray;

begin

SetLength(v, 0);

Result := ThreadSafeCall('Form1_ShowModal', v);

end;

 

Procedure StartForm;

begin

Form1_SafeInit;

Form1_SafeShowModal;

FreeForm(Form1);

end;

 

begin

StartForm;

end.

[/scar]

Edited by shadowrecon
Link to comment
Share on other sites

This is almost what your looking for. It may need alittle tweaking on the Row/Col X,Y numbers but i ran it trough a test and it gives the correct slot for which ever box is picked. Hope this helps you understand it a little better

[scar]

program New;

{$Define RS2}

{.include OSI\OSI.scar}

 

var

Form1: TForm;

Image1: TImage;

Slot: Integer;

 

Procedure SetupImage; // Retunrs picture of bank screen with Boxes around ea item

var

I,II,BMP,W,H: Integer;

Canvas,SCanvas: TCanvas;

TPA: TPointArray;

Begin

// Making the bitmap and filling in the boxes

BMP := BitmapFromString(MBPW,MBPH,'');

CopyClientToBitmap(BMP,MBX1,MBY1,MBX2-46,MBY2+10);

For I := 0 to 49 do

Begin

TPA := TBOutlineToTPA(Box(5 + ((I mod 10) * 44),5+((I div 10) * 44), 40 + ((I mod 10) * 44), 38 + ((I div 10) * 44)));

For II := 0 to High(TPA) do

FastSetPixel(BMP, TPA[iI].X, TPA[iI].Y, clRed);

end;

 

// Seting the bitmap as the form back ground

SCanvas := Image1.Canvas;

Canvas := GetBitmapCanvas(BMP);

GetBitmapSize(BMP, W, H);

SafeCopyCanvas(Canvas, SCanvas, 0, 0, W, H, 0, 0, W, H);

freeBitmap(BMP);

end;

 

Procedure SetupSlots(Sender: TObject);

Var

X,Y: Integer;

Row,Col: Integer;

HWDC: Integer;

Begin

 

HWDC := GetClientWindowHandle; // Store Client

SetClientWindowHandle(Form1.Handle);// SetForm as client

 

GetMousePos(X,Y);

 

X := X - 8; // These remove the border of the form

Y := Y - 30;

 

Writeln( 'X: '+InttoStr(X)+' Y: '+InttoStr(Y) );

 

Case Y of // Increments of 40

0..40: Row := 1;// First Row

41..82: Row := 2;// Second Row

83..124: Row := 3;

125..165: Row := 4;

166..214: Row := 5;

end;

 

Case X of // Increments of 40

0..40: Col := 1;// First Col

41..82: Col := 2;// Second Col

83..124: Col := 3;

125..165: Col := 4;

166..206: Col := 5;

207..247: Col := 6;

248..288: Col := 7;

289..328: Col := 8;

329..368: Col := 9;

369..444: Col := 10;

end;

 

Writeln( 'Row: '+InttoStr(Row)+' Col: '+InttoStr(Col) );

Slot := GetBankSlotIndex(Row,Col);

 

Writeln('Slot: '+InttoStr(Slot));

SetClientWindowHandle(HWDC);// Return to orginal Client

end;

 

procedure Form1_Init;

begin

Form1 := CreateForm;

Image1 := TImage.Create(Form1);

with Form1 do

begin

ClientHeight := MBPH+10;

ClientWidth := MBPW-46;

OldCreateOrder := False;

PixelsPerInch := 96;

end;

with Image1 do

begin

Parent := Form1;

OnClick :=@SetupSlots;

Left := 0;

Top := 0;

Width := MBPW-46;

Height := MBPH+10;

end;

 

SetupImage; // Setup image and displays it on form

 

end;

 

procedure Form1_SafeInit;

var

v: TVariantArray;

begin

SetLength(v, 0);

ThreadSafeCall('Form1_Init', v);

end;

 

function Form1_ShowModal: Boolean;

begin

Result := Form1.ShowModal = mrOk;

end;

 

function Form1_SafeShowModal: Boolean;

var

v: TVariantArray;

begin

SetLength(v, 0);

Result := ThreadSafeCall('Form1_ShowModal', v);

end;

 

Procedure StartForm;

begin

Form1_SafeInit;

Form1_SafeShowModal;

FreeForm(Form1);

end;

 

begin

StartForm;

end.

[/scar]

 

Thank you very much for this. This inspired much, and helped on the code, but i preffer to do it by myself, and not just copy urs, to learn and understand everything :-)

 

---------- Post added at 01:39 PM ---------- Previous post was at 12:49 PM ----------

 

After inspiration from u shadow i made this:

 

[sCAR]procedure DrawLineImg(Sender: TObject);

var

BitMap, i: Integer;

TB: TBox;

TPA: TPointArray;

x, y: Integer;

Slot: Integer;

begin

DCB := GetClientWindowHandle;

SetClientWindowHandle(IngPick.Handle);

GetMousePos(x, y);

exit;

Case Y of

33..77: Row := 1;

78..122: Row := 2;

123..167: Row := 3;

168..212: Row := 4;

end;

 

Case X of

11..55: Col := 1;

56..100: Col := 2;

100..145: Col := 3;

146..190: Col := 4;

191..258: Col := 5;

259..235: Col := 6;

236..280: Col := 7;

281..325: Col := 8;

326..370: Col := 9;

371..415: Col := 10;

end;

 

Slot := (Col * 10) - 10 + Row;[/sCAR]

 

But for some reason the GetMousePos(x, y) shut down my scar instant :o? Is it a bug or :P?

 

And how do i use the original GetMousePos and not the SmartGetMousePos (That is named as GetMousePos too)

meaby that solve the problem :P

 

---------- Post added at 04:13 PM ---------- Previous post was at 01:39 PM ----------

 

Ok i found out that it is because smart overwrite the function GetMousePos and makes it unvalid (on some way) when used in other forms then SMART.

 

Is there a way to undefine smart for a second and then define it again? I think i needs Freddy or Wanted's help (It meaby helps saying their names xD)

Link to comment
Share on other sites

Thank you very much for this. This inspired much, and helped on the code, but i preffer to do it by myself, and not just copy urs, to learn and understand everything :-)

 

---------- Post added at 01:39 PM ---------- Previous post was at 12:49 PM ----------

 

After inspiration from u shadow i made this:

 

[sCAR]procedure DrawLineImg(Sender: TObject);

var

BitMap, i: Integer;

TB: TBox;

TPA: TPointArray;

x, y: Integer;

Slot: Integer;

begin

DCB := GetClientWindowHandle;

SetClientWindowHandle(IngPick.Handle);

GetMousePos(x, y);

exit;

Case Y of

33..77: Row := 1;

78..122: Row := 2;

123..167: Row := 3;

168..212: Row := 4;

end;

 

Case X of

11..55: Col := 1;

56..100: Col := 2;

100..145: Col := 3;

146..190: Col := 4;

191..258: Col := 5;

259..235: Col := 6;

236..280: Col := 7;

281..325: Col := 8;

326..370: Col := 9;

371..415: Col := 10;

end;

 

Slot := (Col * 10) - 10 + Row;[/sCAR]

 

But for some reason the GetMousePos(x, y) shut down my scar instant :o? Is it a bug or :P?

 

And how do i use the original GetMousePos and not the SmartGetMousePos (That is named as GetMousePos too)

meaby that solve the problem :P

 

---------- Post added at 04:13 PM ---------- Previous post was at 01:39 PM ----------

 

Ok i found out that it is because smart overwrite the function GetMousePos and makes it unvalid (on some way) when used in other forms then SMART.

 

Is there a way to undefine smart for a second and then define it again? I think i needs Freddy or Wanted's help (It meaby helps saying their names xD)

 

You have to make sure with the client handles you are managing them correctly. You need a local Var to store your clients handle and make sure after you finish with your function you switch back to the original client handle. < What i think the problem is is after you close the form its still set as the client and you never returned back to the original client.

Link to comment
Share on other sites

You have to make sure with the client handles you are managing them correctly. You need a local Var to store your clients handle and make sure after you finish with your function you switch back to the original client handle. < What i think the problem is is after you close the form its still set as the client and you never returned back to the original client.

 

Nope that's not my problem, i do have set it to do that (Just didn't copied it in here). I have debugged everything and the problem is GetMousePos(). I need to use the normal GetMousePos() and not SmartGetMousePos. Is there a "2nd" function for GetMousePos()?

Link to comment
Share on other sites

I found a solution :-D

 

I just used the MousePos() instead of GetMousePos. I dont really know why the other one didn't work :S

 

---------- Post added 03-30-2012 at 07:32 PM ---------- Previous post was 03-29-2012 at 09:15 PM ----------

 

Wow this drawing coding isn't really me. Now im stuck again -.-.

 

Im trying to make the image that ur hovering be highlighted with a blue color at the bounds and when you click it turns green (Gonna make that after when i know how to to this :S)

 

I have made it draw some blue lines when im hovering the mouse over the image:

 

[sCAR]

function GetBounds(Slot: Integer): TBox;

begin

Result := Box(11 + ((Slot mod 10) * 44), 33 + ((Slot div 10) * 44), 54 + ((Slot mod 10) * 44), 76 + ((Slot div 10) * 44));

end;

 

function GetSlot: Integer;

var

x, y, i: Integer;

begin

x := MousePos.X;

y := MousePos.Y;

for i := 0 to 39 do begin

if MouseInBox(GetBounds(i)) then begin

result := i;

end;

end;

end;

 

procedure DrawLineImg(Sender: TObject);

var

i: Integer;

TB: TBox;

Canvas: TCanvas;

BitMap: Integer;

TPA: TPointArray;

Slot: Integer;

begin

DCB := GetClientWindowHandle;

SetClientWindowHandle(IngPick.Handle);

Slot := GetSlot;

TB := GetBounds(slot)

 

Bitmap := BitmapFromString(455, 210, '');

Canvas := GetBitmapCanvas(BitMap);

FastDrawClear(Bitmap, clBlack);

SetTransparentColor(Bitmap, clBlack);

 

//Making green lines

TB := Box(TB.X1 + 10, TB.Y1 + 10, TB.X2 - 10, TB.Y2 - 10);

TPA := TBOutlineToTPA(TB);

for i := 0 to High(TPA) do begin

FastSetPixel(BitMap, TPA.X, TPA.Y, clBlue);

FastSetPixel(BitMap, TPA.X - 1, TPA.Y - 1, clBlue);

end;

 

SafeCopyCanvas(Canvas, Image[slot].Canvas, TB.X1, TB.Y1, TB.X2, TB.Y2, 0, 0, 44, 44);

FastDrawClear(BitMap, clBlack);

SetClientWindowHandle(DCB);

Freebitmap(Bitmap);

end;

[/sCAR]

But i just dont understand why the image turns black and how i clear all the images before drawing the blue line :-(

 

If you can't just see it out of the code i can upload the full script but only if u can't :P

Edited by sjesper
Link to comment
Share on other sites

This code fills the slots and only takes about 10 lines of code. I based it off the original idea. You would now need a way to remove selected slots by doing this. You could also instead of filling the slot with a solid color just change the outline of the box which would make selecting/deselecting alot easier but the process is basically the same just remove the filling function and replace it with the same function that creates the boxes but instead of looping through all of them just do the slot that was selected.

[scar]

program New;

{$Define RS2}

{.include OSI\OSI.scar}

 

var

Form1: TForm;

Image1: TImage;

Slot: Integer;

 

Procedure SetupImage; // Retunrs picture of bank screen with Boxes around ea item

var

I,II,BMP,W,H: Integer;

Canvas,SCanvas: TCanvas;

TPA: TPointArray;

Begin

// Making the bitmap and filling in the boxes

BMP := BitmapFromString(MBPW,MBPH,'');

CopyClientToBitmap(BMP,MBX1,MBY1,MBX2-46,MBY2+10);

For I := 0 to 49 do

Begin

TPA := TBOutlineToTPA(Box(5 + ((I mod 10) * 44),5+((I div 10) * 44), 40 + ((I mod 10) * 44), 38 + ((I div 10) * 44)));

For II := 0 to High(TPA) do

FastSetPixel(BMP, TPA[iI].X, TPA[iI].Y, clRed);

end;

 

// Seting the bitmap as the form back ground

SCanvas := Image1.Canvas;

Canvas := GetBitmapCanvas(BMP);

GetBitmapSize(BMP, W, H);

SafeCopyCanvas(Canvas, SCanvas, 0, 0, W, H, 0, 0, W, H);

freeBitmap(BMP);

end;

 

Procedure CoverSlot(Color, Slot: Integer);

Var

BMP,I,II: Integer;

Begin

BMP := BitmapFromString(40,40,'');

For I := 0 to 39 do // Width

For II := 0 to 39 do // Height

FastSetPixel(BMP,I,II,Color);

SafeDrawBitmap(BMP,Image1.Canvas,5 + ((Slot mod 10) * 44), 5+((Slot div 10) * 44));

FreeBitmap(BMP);

end;

 

Procedure SetupSlots(Sender: TObject);

Var

X,Y: Integer;

Row,Col: Integer;

HWDC: Integer;

Begin

HWDC := GetClientWindowHandle; // Store Client

SetClientWindowHandle(Form1.Handle);// SetForm as client

 

GetMousePos(X,Y);

 

X := X - 8; // These remove the border of the form

Y := Y - 30;

 

Writeln( 'X: '+InttoStr(X)+' Y: '+InttoStr(Y) );

 

Case Y of // Increments of 40

0..40: Row := 1;// First Row

41..82: Row := 2;// Second Row

83..124: Row := 3;

125..165: Row := 4;

166..214: Row := 5;

end;

 

Case X of // Increments of 40

0..40: Col := 1;// First Col

41..82: Col := 2;// Second Col

83..124: Col := 3;

125..165: Col := 4;

166..206: Col := 5;

207..247: Col := 6;

248..288: Col := 7;

289..328: Col := 8;

329..368: Col := 9;

369..444: Col := 10;

end;

 

Writeln( 'Row: '+InttoStr(Row)+' Col: '+InttoStr(Col) );

Slot := GetBankSlotIndex(Row,Col);

 

Writeln('Slot: '+InttoStr(Slot));

SetClientWindowHandle(HWDC);// Return to orginal Client

 

CoverSlot(clBlack, Slot); // Fills Slot

end;

 

procedure Form1_Init;

begin

Form1 := CreateForm;

Image1 := TImage.Create(Form1);

with Form1 do

begin

ClientHeight := MBPH+10;

ClientWidth := MBPW-46;

OldCreateOrder := False;

PixelsPerInch := 96;

end;

with Image1 do

begin

Parent := Form1;

OnClick :=@SetupSlots;

Left := 0;

Top := 0;

Width := MBPW-46;

Height := MBPH+10;

end;

 

SetupImage; // Setup image and displays it on form

 

end;

 

procedure Form1_SafeInit;

var

v: TVariantArray;

begin

SetLength(v, 0);

ThreadSafeCall('Form1_Init', v);

end;

 

function Form1_ShowModal: Boolean;

begin

Result := Form1.ShowModal = mrOk;

end;

 

function Form1_SafeShowModal: Boolean;

var

v: TVariantArray;

begin

SetLength(v, 0);

Result := ThreadSafeCall('Form1_ShowModal', v);

end;

 

Procedure StartForm;

begin

Form1_SafeInit;

Form1_SafeShowModal;

FreeForm(Form1);

end;

 

begin

StartForm;

end.

[/scar]

Link to comment
Share on other sites

This code fills the slots and only takes about 10 lines of code. I based it off the original idea. You would now need a way to remove selected slots by doing this. You could also instead of filling the slot with a solid color just change the outline of the box which would make selecting/deselecting alot easier but the process is basically the same just remove the filling function and replace it with the same function that creates the boxes but instead of looping through all of them just do the slot that was selected.

[scar]

program New;

{$Define RS2}

{.include OSI\OSI.scar}

 

var

Form1: TForm;

Image1: TImage;

Slot: Integer;

 

Procedure SetupImage; // Retunrs picture of bank screen with Boxes around ea item

var

I,II,BMP,W,H: Integer;

Canvas,SCanvas: TCanvas;

TPA: TPointArray;

Begin

// Making the bitmap and filling in the boxes

BMP := BitmapFromString(MBPW,MBPH,'');

CopyClientToBitmap(BMP,MBX1,MBY1,MBX2-46,MBY2+10);

For I := 0 to 49 do

Begin

TPA := TBOutlineToTPA(Box(5 + ((I mod 10) * 44),5+((I div 10) * 44), 40 + ((I mod 10) * 44), 38 + ((I div 10) * 44)));

For II := 0 to High(TPA) do

FastSetPixel(BMP, TPA[iI].X, TPA[iI].Y, clRed);

end;

 

// Seting the bitmap as the form back ground

SCanvas := Image1.Canvas;

Canvas := GetBitmapCanvas(BMP);

GetBitmapSize(BMP, W, H);

SafeCopyCanvas(Canvas, SCanvas, 0, 0, W, H, 0, 0, W, H);

freeBitmap(BMP);

end;

 

Procedure CoverSlot(Color, Slot: Integer);

Var

BMP,I,II: Integer;

Begin

BMP := BitmapFromString(40,40,'');

For I := 0 to 39 do // Width

For II := 0 to 39 do // Height

FastSetPixel(BMP,I,II,Color);

SafeDrawBitmap(BMP,Image1.Canvas,5 + ((Slot mod 10) * 44), 5+((Slot div 10) * 44));

FreeBitmap(BMP);

end;

 

Procedure SetupSlots(Sender: TObject);

Var

X,Y: Integer;

Row,Col: Integer;

HWDC: Integer;

Begin

HWDC := GetClientWindowHandle; // Store Client

SetClientWindowHandle(Form1.Handle);// SetForm as client

 

GetMousePos(X,Y);

 

X := X - 8; // These remove the border of the form

Y := Y - 30;

 

Writeln( 'X: '+InttoStr(X)+' Y: '+InttoStr(Y) );

 

Case Y of // Increments of 40

0..40: Row := 1;// First Row

41..82: Row := 2;// Second Row

83..124: Row := 3;

125..165: Row := 4;

166..214: Row := 5;

end;

 

Case X of // Increments of 40

0..40: Col := 1;// First Col

41..82: Col := 2;// Second Col

83..124: Col := 3;

125..165: Col := 4;

166..206: Col := 5;

207..247: Col := 6;

248..288: Col := 7;

289..328: Col := 8;

329..368: Col := 9;

369..444: Col := 10;

end;

 

Writeln( 'Row: '+InttoStr(Row)+' Col: '+InttoStr(Col) );

Slot := GetBankSlotIndex(Row,Col);

 

Writeln('Slot: '+InttoStr(Slot));

SetClientWindowHandle(HWDC);// Return to orginal Client

 

CoverSlot(clBlack, Slot); // Fills Slot

end;

 

procedure Form1_Init;

begin

Form1 := CreateForm;

Image1 := TImage.Create(Form1);

with Form1 do

begin

ClientHeight := MBPH+10;

ClientWidth := MBPW-46;

OldCreateOrder := False;

PixelsPerInch := 96;

end;

with Image1 do

begin

Parent := Form1;

OnClick :=@SetupSlots;

Left := 0;

Top := 0;

Width := MBPW-46;

Height := MBPH+10;

end;

 

SetupImage; // Setup image and displays it on form

 

end;

 

procedure Form1_SafeInit;

var

v: TVariantArray;

begin

SetLength(v, 0);

ThreadSafeCall('Form1_Init', v);

end;

 

function Form1_ShowModal: Boolean;

begin

Result := Form1.ShowModal = mrOk;

end;

 

function Form1_SafeShowModal: Boolean;

var

v: TVariantArray;

begin

SetLength(v, 0);

Result := ThreadSafeCall('Form1_ShowModal', v);

end;

 

Procedure StartForm;

begin

Form1_SafeInit;

Form1_SafeShowModal;

FreeForm(Form1);

end;

 

begin

StartForm;

end.

[/scar]

 

Thank you very much ! Now i understand. When i draw a bitmap on a canvas the background is black and because of that i need to make the background the background of the image. I've been trying to figuring this out the past days but looking at the wrong code.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...