subclassing

Subclassing Array

If you're not interested in a story, skip the first 2 paragraphs. I was talking to a friend about arrays and why they (still) crash if you try to access an object that is out of bounds in "modern" languages like Objective C (That's my main language). So we got into a debate and I said that I could write him an Array (I named it GeniusAr...

Method overriding and visibility in Java

Why does the compiler give an error message when you reduce the visibility of a method while overriding it in the subclass? ...

I Don't get the WM_GETMINMAXINFO message from other applications

Hello! In my C-Dll there is a Windows hook: hook = SetWindowsHookEx(WH_CALLWNDPROC, CallWndProc, hinstance, 0); With this Callback method: LRESULT CALLBACK CallWndProc(int nCode, WPARAM wParam, LPARAM lParam) { ... CWPSTRUCT* cw = reinterpret_cast<CWPSTRUCT*>(lParam); myfile << "CallWndProc allg. " << cw->message << "\n"; if (cw->...

Overload method (specifically drawRect:) without subclassing.

I'm using a container UIView to house a UIImageView and do some custom drawing. At this point I'd like to do some drawing on top of my subview. So overriding drawRect: in my container UIView will only draw below the subviews. Is there a way to overload drawRect: in my subview without subclassing it? I think method swizzling may be th...

Choosing the right subclass to instantiate programatically

Ok, the context is some serialization / deserialization code that will parse a byte stream into an 'object' representation that's easier to work with (and vice-versa). Here's a simplified example with a base message class and then depending on a 'type' header, some more data/function are present and we must choose the right subclass to ...

Hooks or Subclassing on 3rd party ActiveX

Can we hook or sub-class a 3rd party activeX ocx like acrobat reader control such that it cannot receive WM_LBUTTONDOWN message? If yes then how it is possible ? Thanks in advance Regards, Naeem ...

Delphi: Proper time to subclass, and restore, a control?

What is the correct place/time to start subclassing a control? What is the proper time to restore the original window proc? Right now i subclass during form creation: procedure TForm1.FormCreate(Sender: TObject); begin FOldPanel1WindowProc := Panel1.WindowProc; Panel1.WindowProc := Panel1WindowProc; end; and i restore the subc...

public datagridview within user control is "locked" during design time when subclassing

I have a user control that has among other things a label AND a textbox control. With this class, I set the textbox to have its modifier as "public", so when I subclass THIS control, I can get directly to the properties and such of the textbox in each instance where needed. No problem. Now, the problem. I do the exact same thing but ...

C#: Getting label injected into native app's statusbar pane to show up

Hey everyone, I am writing a .Net COM DLL that runs inside a native Windows application. I am attempting to inject an additional pane into this app's statusbar, and it does not have any specific implementation to do so, so I am trying to subclass the app's statusbar myself. I am using the Win32 API SetParent() to switch the parent of ...

Automapping subclass in Fluent NHibernate

I'm having some trouble getting fluent nhibernate to properly map the class hierarchy that I have. Presuming that I have the following class structure public abstract class MedicationAction { ... Id and other attributes public virtual MedicationStatus MedStatus { get; protected set; } } public class CeaseAction : MedicationActio...

Constructor with an array of subclasses of an abstract class as a parameter

I'm working on a player inventory system for a game. I have a struct Slot which has a List<Loot> collection that represents which kinds of items are allowed in it. The abstract class Loot is subclassed by all items which are lootable - i.e.: would be valid Content values for the Slot struct. I want to express that a Slot can have res...

How to draw a picture instead of the slider on Qt QSlider?

I have created a class that inherits from QSlider. I want to draw a picture on the slider (grabber) instead of showing the plain one. How to do it? -- I found an answer and posted after I had received the reply. With due respect to the responder, I will choose that reply. However, I'd like to share code so that anyone with the same iss...

Why doesn't Apple allow subclassing of UINavigationController? And what are my alternatives to subclassing?

I'm currently building a tabbed iPhone application where each tab's view controller is an instance of UINavigationController, and where every subcontroller of every one of the UINavigationController instances is an instance of UITableViewController. Ideally, I'd like to subclass UINavigationController so that the controller for each tab ...

C#: What is destroying my NativeWindow object and why?

I am using a NativeWindow object to subclass an unmanaged window's message pump, with the purpose of intercepting its messages. Code structure looks something like this (its psuedo C#, please excuse minor syntax problems): class AppSubclass : Control { class SpecialAppWndProc : NativeWindow { protected override void WndProc(ref Me...

C#: Marshalling a "pointer to an int array" from a SendMessage() lParam

I'm trying to subclass an unmanaged statusbar window from my managed COM server using a class inherited from NativeWindow, and am running into a wall trying to make sense of how to properly marshal the contents of an lParam. http://msdn.microsoft.com/en-us/library/bb760757%28VS.85%29.aspx says that the contents of this lParam is of type...

When subclassing in AS3, is a new constructor function necessary?

Basic OOP question... I want to add a couple functions to the Array class so that my program will be amazing and make me rich and famous overnight. So I create a new subclass NewArray which extends Array. Do I need to write a constructor method for NewArray? If I leave it blank will it just use the parent's (Array's) constructor metho...

Subclassing Decimal in Python

I want to use Decimal class in my Python program for doing financial calculations. Decimals to not work with floats - they need explicit conversion to strings first. So i decided to subclass Decimal to be able to work with floats without explicit conversions. m_Decimal.py: # -*- coding: utf-8 -*- import decimal Decimal = decimal.Decim...

Python: file with programmer-defined attributes

Using Python 2.5, I'd like to create a temporary file, but add (& modify) attributes of my own. I've tried the following: class TempFileWithAttributes ( ) : __slots__ = [ '_tempFile' , 'Value' ] def __init__ ( self ) : self._tempFile = tempfile.TemporaryFile() object.__setattr__ ( self, '_tempFile', t...

Sample (preferably simple) subclass of NSCoder?

I'm trying to create a subclass of NSCoder, but I really don't know where to start. Apple's documentation lists which methods are required, but not much else. Maybe my Google-fu is weak, but I can't find any examples of an implementation of, e.g. encodeValueOfObjCType:at:, anywhere. (Though I assume it involves a lot of cases.) Anyone k...

Safely remove window subclassing?

I am trying to subclass the currently focused window on a Windows system using a global CBT hook. This is related to what happens in this question, but the bug is different. What happens when this subclassing is in effect, is that Opera's (version 10.50) main window is prevented from displaying. Opera has a "splash screen" where you are...