ADC Home > Reference Library > Technical Q&As > QuickTime > QuickTime for Windows >

CreatePortAssociation And WM_QUERYNEWPALETTE Message

Q Under QuickTime 3 for Windows, my window procedure never receives WM_QUERYNEWPALETTE messages if I've called CreatePortAssociation in the same window procedure on WM_CREATE events. What's going on?

A You are right in that the window procedure for the HWND does not get forwarded the WM_QUERYNEWPALETTE message. To get around this, you can use the Mac toolbox functions NSetPalette and ActivatePalette to activate your custom palette. However, because of this anomaly in QTML (not forwarding this message), you need to work around it by capturing the WndProc and calling back through for all messages except the palette one (because you'll use NSetPalette and ActivatePalette to assert the palette instead). Here's a code snippet which illustrates this:
qtmlWndProc = SetWindowLong(hWnd, GWL_WNDPROC, MyNewWndProc);

LRESULT CALLBACK MyWndProc()
{
  if (message == WM_QUERYNEWPALETTE)
  {
    // do your thing
  }
  else
    CallWindowProc(qtmlWndProc, ...);
}

Note that this is kind of messy since you need to avoid going recursive with QTML calling back to you from within that CallWindowProc.

Of course, you can always use the Win32 palette routines anywhere in your code to assert a custom palette. After you change the color environment, simply ensure that you make the QuickTime GDevice match. Here's pseudo-code describing how to make the GDevice match:

1) Call SelectPalette and RealizePalette to change the hardware palette
2) Call GetSystemPaletteEntries to get the colors back from Windows
3) Convert the palette entries into a QuickTime ColorTable
4) Move the color table entries into the (**(**GetMainDevice()).gdPMap).pmTable

Note also you can create a custom palette and associate it with your movie using the QuickTime 3 GetMovieColorTable() and SetMovieColorTable() functions. If you're going to display your movie along with a movie controller, and you want the custom palette to be used when the movie is activated, simply use the MCDoAction function and the mcFlagsUseWindowPalette flag.

[Sep 21 1998]


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.