Author Topic: real time wada basin effect  (Read 12716 times)

0 Members and 1 Guest are viewing this topic.

Offline taj

  • Bytes hurt
  • DBF Aficionado
  • ******
  • Posts: 4810
  • Karma: 189
  • Scene there, done that.
    • View Profile
Re: real time wada basin effect
« Reply #20 on: February 20, 2008 »
My special version works fine  :P

I'll help you with a small window dialog if you like, I have all code for it


Yes please!
Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: real time wada basin effect
« Reply #21 on: February 20, 2008 »
@taj:
Hmm ... never did a tiny sized window dialog. Here is
a un-optimized code example of a combo box. Maybe
this helps out.

Code: [Select]
#include <windows.h>

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

HINSTANCE g_hinst;

int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
  HWND hwnd;
  MSG  msg ;   
  WNDCLASS wc = {0};
  wc.lpszClassName = TEXT("Application");
  wc.hInstance     = hInstance ;
  wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
  wc.lpfnWndProc   = WndProc ;
  wc.hCursor       = LoadCursor(0,IDC_ARROW);

  g_hinst = hInstance;
 
  RegisterClass(&wc);
  hwnd = CreateWindow(wc.lpszClassName, TEXT("taj"),
                WS_OVERLAPPEDWINDOW | WS_VISIBLE,
                100, 100, 150, 80, 0, 0, hInstance, 0); 

  while( GetMessage(&msg, NULL, 0, 0)) {
    DispatchMessage(&msg);
  }
  return (int) msg.wParam;
}

LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{

  static HWND hwndCombo; //, hwndStatic;
  const TCHAR *items[] = { TEXT("800x600"), TEXT("1024x768"), TEXT("1280x1024") };
  int i;
  LRESULT sel = 0;

  switch(msg) 
  {
      case WM_CREATE:
            hwndCombo = CreateWindow(TEXT("combobox"), NULL,
                  WS_CHILD | WS_VISIBLE | CBS_DROPDOWN,
                  10, 10, 120, 110, hwnd, NULL, g_hinst, NULL);   

            for ( i = 0; i < sizeof(items) / sizeof(int); i++ ) {
                SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM) items[i]);
            }

            break;

      case WM_COMMAND:
           if (HIWORD(wParam) == BN_CLICKED) {
                SendMessage(hwndCombo, CB_SHOWDROPDOWN, (WPARAM) TRUE, 0);
           }
             
           if ( HIWORD(wParam) == CBN_SELCHANGE) {               
                sel = SendMessage(hwndCombo, CB_GETCURSEL, 0, 0);
//
// items[sel] holds the selected value !!!
//
           }

           break;

      case WM_DESTROY:
          PostQuitMessage(0);
          break;
  }
  return DefWindowProc(hwnd, msg, wParam, lParam);
}

items[sel] holds the selected value of the combobox.

Or do you need other controls like checkboxes, radiobuttons?
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline taj

  • Bytes hurt
  • DBF Aficionado
  • ******
  • Posts: 4810
  • Karma: 189
  • Scene there, done that.
    • View Profile
Re: real time wada basin effect
« Reply #22 on: February 20, 2008 »
Thanks Benny, this seems like a VERY good start. This should really be a subject by itself but in essence:

* Open a dialogue box with a list of items
* Submit the list of options eg "640x480", "800x600" etc..
* Wait until OK button is pressed
* Get the selected item index (number-not text)
* Kill window
* Resize desktop using numbers in array indexed by the return value from dialogue
* Open Opengl window fullscreen

Your example is getting close if I can destroy that window and open the opengl window afterwards.
Unless anyone can think of a smarter way..

OK so I got your code compilingon the front of one of my demos. Really the only strange thing is that I have to exit the app before the demo starts (ie I dont press an OK button). However this is getting very close!!

Wrell done. I make it 330 bytes roughly after crinklering...hopefully we could get it below 200 ... hopefully.

Taj
« Last Edit: February 20, 2008 by taj »
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: real time wada basin effect
« Reply #23 on: February 21, 2008 »
  wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
  wc.hCursor       = LoadCursor(0,IDC_ARROW);
Can just set both of these to NULL.
  wc.hbrBackground = NULL;
  wc.hCursor       = NULL;
Jim
Challenge Trophies Won: