The Code Cave

April 21, 2007

Heading to PA for Easter dinne…

Filed under: Brian Layman — Brian @ 9:30 am

Heading to PA for Easter dinner… late enough to be “fashionable”?

April 20, 2007

Soooo much for the pens…

Filed under: Brian Layman — Brian @ 5:53 pm

Soooo much for the pens…

Capture an image to a fully paletted bitmap

Filed under: Delphi — Brian @ 4:56 pm

This code does not look like it was mine originally, but I found it in a stray file on my hard drive.  I decided I didn’t want to lose it. 

 It takes a picture of any component you pass in and populates a TBitmap with an image using a custom palette built from device context of the component you are capturing.

DELPHI:
  1.  
  2.  
  3. {******************************************************************************
  4.   ComponentToImg
  5.  ******************************************************************************}
  6. procedure TForm1.ComponentToImg(CHandle: HWND; x: Integer; y: Integer; Width: Integer; Height: Integer; bm: TBitMap);
  7. var
  8.   dc: HDC;
  9.   lpPal : PLOGPALETTE;
  10. begin // ComponentToImg
  11.   // Test width and height
  12.   if ((Width = 0) OR (Height = 0)) then exit;
  13.   bm.Width := Width;
  14.   bm.Height := Height;
  15.  
  16.   // Get the screen dc
  17.   dc := GetDc(CHandle);
  18. try
  19. // If the device doesn’t have a handle, we can’t do anything with it.
  20.   if (dc = 0) then exit;
  21.   // Do we have a palette device?
  22.   if (GetDeviceCaps(dc, RASTERCAPS) AND RC_PALETTE = RC_PALETTE)
  23.   then begin
  24.     // If so, allocate memory for a logical palette
  25.     GetMem(lpPal, sizeof(TLOGPALETTE) + (255 * sizeof(TPALETTEENTRY)));
  26.      try
  27.         // Zero it out to be neat
  28.         FillChar(lpPal^, sizeof(TLOGPALETTE) + (255 * sizeof(TPALETTEENTRY)), #0);
  29.         // Fill in the palette version
  30.         lpPal^.palVersion := $300;
  31.         // Grab the system palette entries
  32.         lpPal^.palNumEntries :=GetSystemPaletteEntries(dc,0,256,lpPal^.palPalEntry);
  33.         // Create the palette
  34.         if (lpPal^.PalNumEntries <> 0) then bm.Palette := CreatePalette(lpPal^);
  35.       finally
  36.         FreeMem(lpPal, sizeof(TLOGPALETTE) + (255 * sizeof(TPALETTEENTRY)));
  37.       end;
  38.   end;
  39.   // Copy from the screen to the bitmap}
  40.   BitBlt(bm.Canvas.Handle, 0, 0, Width, Height, Dc, x, y, SRCCOPY);
  41.  
  42.   // Release the screen dc no matter what happened above.
  43. finally
  44.   ReleaseDc(0, dc);
  45. end
  46. end// ComponentToImg
  47.  
  48. procedure TForm1.Button1Click(Sender: TObject);
  49. begin
  50.   ComponentToImg(self.Handle, 0, 0, 800, 600, Image1.Picture.Bitmap);
  51. end;

April 17, 2007

In 3 hr part 2 meeting. pt1 wa…

Filed under: Brian Layman — Brian @ 4:09 pm

In 3 hr part 2 meeting. pt1 was 4hr. 20min to go. @slide 76 of 115! ugggg

April 16, 2007

Lookin’ forward to new and exc…

Filed under: Brian Layman — Brian @ 9:17 pm

Lookin’ forward to new and exciting times comin’ soon.

Listening for the phone.

Filed under: Brian Layman — Brian @ 6:14 pm

Listening for the phone.

@Technosailor: Order one for …

Filed under: Brian Layman — Brian @ 2:59 pm

@Technosailor: Order one for me to go, will ya?

April 15, 2007

Torchwood & PHP code - Perfect…

Filed under: Brian Layman — Brian @ 9:38 pm

Torchwood & PHP code - Perfect together.

April 5, 2007

Techno-sailing through WordPress FAQs

Filed under: WordPress, wp-hackers — Brian @ 8:59 pm

Aaron Brazell is in the middle of a GREAT series on how to enhance WordPress.  He’s been going through several of the questions that have been presented to b5media’s support forum.  I’ve found his solution for Category Based Themes very interesting because I expect the Google Summer of Code 2007 WordPress Project I am mentoring may build upon this and similar solutions.

 Here’s his guide to this series as it exists today:

Series Guide

  1. WordPress FAQ: How Do I combine Blogs?
  2. WordPress FAQ: What’s up with the Amazon Plugin with WP 2.1.x?
  3. WordPress FAQ: How Do I Use Category Themes?
  4. WordPress FAQ: Where did my Preview Link Go?
  5. WordPress FAQ: How Do I Use Child Pages More Effectively?
  6. WordPress FAQ: How Do I Fix the Blogroll Category Issue in WordPress 2.1

I’m looking forward to seeing what else Aaron presents to us!

April 3, 2007

A non-CodeGear patent application on “compiling” Object Pascal code?

Filed under: Borland, CodeGear, Delphi — Brian @ 8:12 pm

I read in the Newsgroups today that there is a new patent that’s been filed that affects what Borland can do with Object Pascal.  According to this patent application, Mirkazemi; Aram; (Lindisfame, AU) ; Besharati; Shahram; (Kingston Beach, AU) would have a US patent upon producing JavaScript code from Delphi’s Object Pascal and several other languages

Who knows if this will fly, but the idea of restricting what a company can do with the product they’ve made is just….  irratating!

A key quote from the patent application:

9. A method for producing a web application that runs natively in a browser, comprising: writing in a high-level language to develop a source file; parsing the source file to produce a semantic map; and processing the semantic map by emitting browser-side JavaScript comprising at least one dispatcher having a set of parameters to invoke a code segment utilizing the same set of parameters.

10. The method of claim 9 wherein the high-level language comprises a high-level language from among the programming languages consisting of Ada, C, C++, C#, COBOL, ColdFusion, Common Lisp, Delphi, Fortran, Java, Object Pascal, SmallTalk, Visual Basic, and Visual Basic.NET.  

So, this program will take all Delphi source code and forms and convert them to a web app in javascript.

 First, I think it is hilarious to hear javascript described as a low level language, but that’s beside the point.

If Borland wanted to provide javascript as a target, as they do .NET and W32, they SHOULD be allowed to.  It is THEIR product.  They of course would have to do the work themselves, but it is a programming language they’ve made.  Why should they be restricted?  Especially when they’ve been nice folks and allowed programs like Free Pascal the benifit of the Delphi’s innovation.

 BAH!  It’ll probably pass with a rubber stamp of approval.

« Older PostsNewer Posts »

Powered by WordPress