Bill Farmer

Random thoughts on random subjects

Handling Resizing in Windows

by Bill Farmer. Categories: Hacking .

I have a windows app where I want the app window to maintain it’s aspect ratio when it is resized. Windows provides two mechanisms for this, the WM_SIZE message and the WM_SIZING message. The WM_SIZE message is sent when a window has been resized to allow child windows to be resized, the WM_SIZING message is sent while the user is resizing it to allow the size to be adjusted. The messages are handled in the WindowProc callback function.

Read more →

Swift

by Bill Farmer. Categories: Hacking .

Some years ago I wrote an OSX app in C using Carbon because my Hackintosh would only run OSX 10.4 (Tiger). The most difficult part was dealing with the Core Audio API. I recently decided to port it to Swift to avoid having to attempt to learn Objective C. A derivation of C that sends selectors to targets using the syntax [target selector arguments...] I don’t want to know about.

Read more →

Android Custom Attributes

by Bill Farmer. Categories: Hacking .

I had resisted adding a dark theme to my Diary app until now because it uses a custom calendar with built in customisable styles and preferences with icons. So I had to work out how to make the custom styles of the calendar revert to styles from the current theme, and how to switch icons for the preferences according to the theme. Calendar custom styles The custom calendar has a list of styles that are customisable in a attrs.

Read more →

Android Recent Files

by Bill Farmer. Categories: Hacking .

There are several parts to this - creating the list of files, saving the list in the preferences, restoring the list on startup and creating the list in the menu. // onCreate @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); // Create a map of scroll positions by file name Set<String> pathSet = preferences.getStringSet(PREF_PATHS, null); pathMap = new HashMap<String, Integer>(); if (pathSet != null) for (String path : pathSet) pathMap.

Read more →

Android Text Search

by Bill Farmer. Categories: Hacking .

The Android guide for Search Overview is oriented towards searching external content rather than text. There is a mention of Using the Search Dialog. However all the bits you need are there. To get a search dialog in the toolbar that pops up when needed, you need a seach item in the menu. It should be the first item, unless there is a good reason otherwise. <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.

Read more →
Previous page Next page