Search Results

Search found 2 results on 1 pages for 'darkwalker'.

Page 1/1 | 1 

  • Inherited TShape.Paint does not work after overriding Shape property

    - by DarkWalker
    I'm to code a TExpandedShape class inherited from TShape. TExpandedShape must act like TShape and be able to draw extra shapes: Polygon and Star. Here is my code unit ExpandedShape; interface uses SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, Windows; type TExpandedShapeType = ( stRectangle, stSquare, stRoundRect, stRoundSquare, stEllipse, stCircle, stPolygon, stStar ); TExpandedShape = class(TShape) private FShape: TExpandedShapeType; FEdgeCount: integer; procedure SetShape(const Value: TExpandedShapeType); procedure SetEdgeCount(const Value: integer); public procedure Paint; override; published property Shape : TExpandedShapeType read FShape write SetShape;// default stPolygon; property EdgeCount : integer read FEdgeCount write SetEdgeCount default 5; end; procedure Register; implementation procedure Register; begin RegisterComponents('Course', [TExpandedShape]); end; // TExpandedShape procedure TExpandedShape.Paint; begin case Shape of stStar : begin {Draw Star} end; stPolygon : begin {Draw Polygon} end; else begin {It is supposed to draw Circle, Rectangle etc, but it does not} inherited; end; end; end; procedure TExpandedShape.SetEdgeCount(const Value: integer); begin FEdgeCount := Value; Repaint; end; procedure TExpandedShape.SetShape(const Value: TExpandedShapeType); begin FShape := Value; Repaint; end; end. So, what is wrong? IMO TShape.Paint checks private value like FShape in case section and then decides what to draw. When inherited Paint method is called in my code it checks FShape value sees default 0 value [stRectangle] in there and draws it. PS: I did solve it with blackmagic way using Shape1 property instead of Shape one and if Shape1 value is not stPolygon or stStar i do like this: begin Shape := TShapeType(Shape1); inherited end; But this option is not really an option. I need a good short nice-looking one.

    Read the article

  • How to obtain the first cluster of the directory's data in FAT using C# (or at least C++) and Win32A

    - by DarkWalker
    So I have a FAT drive, lets say H: and a directory 'work' (full path 'H:\work'). I need to get the NUMBER of the first cluster of that directory. The number of the first cluster is 2-bytes value, that is stored in the 26th and 27th bytes of the folder enty (wich is 32 bytes). Lets say I am doing it with file, NOT a directory. I can use code like this: static public string GetDirectoryPtr(string dir) { IntPtr ptr = CreateFile(@"H:\Work\dover.docx", GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0,//FILE_FLAG_BACKUP_SEMANTICS, IntPtr.Zero); try { const uint bytesToRead = 2; byte[] readbuffer = new byte[bytesToRead]; if (ptr.ToInt32() == -1) return String.Format("Error: cannot open direcotory {0}", dir); if (SetFilePointer(ptr, 26, 0, 0) == -1) return String.Format("Error: unable to set file pointer on file {0}", ptr); uint read = 0; // real count of read bytes if (!ReadFile(ptr, readbuffer, bytesToRead, out read, 0)) return String.Format("cant read from file {0}. Error #{1}", ptr, Marshal.GetLastWin32Error()); int result = readbuffer[0] + 16 * 16 * readbuffer[1]; return result.ToString();//ASCIIEncoding.ASCII.GetString(readbuffer); } finally { CloseHandle(ptr); } } And it will return some number, like 19 (quite real to me, this is the only file on the disk). But I DONT need a file, I need a folder. So I am puttin FILE_FLAG_BACKUP_SEMANTICS param for CreateFile call... and dont know what to do next =) msdn is very clear on this issue http://msdn.microsoft.com/en-us/library/aa365258(v=VS.85).aspx It sounds to me like: "There is no way you can get a number of the folder's first cluster". The most desperate thing is that my tutor said smth like "You are going to obtain this or you wont pass this course". The true reason why he is so sure this is possible is because for 10 years (or may be more) he recieved the folder's first cluster number as a HASH of the folder's addres (and I was stupid enough to point this to him, so now I cant do it the same way) PS: This is the most spupid task I have ever had!!! This value is not really used anythere in program, it is only fcking pointless integer.

    Read the article

1