Recompile GTK/GDK and GDK message pump



Hi List,

New user to GTK, WinXP, Dev-Cpp 5beta,
having 2.6.5 glib, gtk+ 2.6.8
libglade 2.5.1, glade2.10.1(devel)
From  http://gladewin32.sourceforge.net/index.php
2.6.8 source from Tor's page http://www.gimp.org/~tml/gimp/win32/downloads.html

The project that I'm starting will use Glad with GTK+, on XP and Linux, accessing a C wrapper to a C++ api, (or other API, hense the wrapper). The application will have need to get to the message pump in GDK and then likely having to rebuild the GDK at the least, if not GTK/glib.

I looked through the archives, but to little avail on either of these...

1) Is there a tutorial on recompiling all of or segments of win32gtk/gdk ?

2) The API/wrapper requires access back into the Glade/Gtk application for callbacks which appears as having to hook into GDK's \gtk+-2.6.8\gdk\win32\gdkevents-win32.c file. Are there any examples or schemes that might demonstrate shared access to GTK's message pump, such that one can reliably exchange messages?

3) Else, is there a doc file, that explains the threading approch or interfacing with gdkevents-win32 method?

A .c based example of the callback configuration is provided below, toward trying to figure out how to do this from within GTK.

Thanks much for any wisdom that might shed some light for a new developer in GTK.

Mike


// Code //
#include "windows.h"
#include "stdio.h"  // printf()

#include "test.h"

HINSTANCE MainInstance;
int CmdShow;

const char* AppName = "WinHello";

HWND listbox;


LRESULT _stdcall WindowProc(HWND Window, UINT AMessage, WPARAM WParam, LPARAM LParam)
{
HDC dc;
PAINTSTRUCT ps;
RECT r;

switch(AMessage) {
 case WM_PAINT:
  dc=BeginPaint(Window,&ps);
  GetClientRect(Window,&r);
DrawText(dc,"On a clear disk, you can seek forever",-1,&r, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
  EndPaint(Window,&ps);
  return 0;

 case WM_DESTROY:
  PostQuitMessage(0);
  return 0;
}

return DefWindowProc(Window, AMessage, WParam, LParam);
}

// Register the Window Class
BOOL WinRegister(void)
{
WNDCLASS WindowClass;

WindowClass.style = CS_HREDRAW | CS_VREDRAW;
WindowClass.lpfnWndProc = WindowProc;
WindowClass.cbClsExtra = 0;
WindowClass.cbWndExtra = 0;
WindowClass.hInstance = MainInstance;
WindowClass.hIcon = LoadIcon(0, IDI_APPLICATION);
WindowClass.hCursor = LoadCursor(0, IDC_ARROW);
WindowClass.hbrBackground = GetStockObject(WHITE_BRUSH);
WindowClass.lpszMenuName = NULL;
WindowClass.lpszClassName = AppName;

return RegisterClass(&WindowClass) != 0;
}

// Create the Window Class
HWND WinCreate(void)
{
HWND hWindow;
hWindow = CreateWindow(AppName, "TestWnd",
WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT,
             CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, MainInstance, NULL);

if(hWindow) {
 ShowWindow(hWindow, CmdShow);
 ShowWindow(hWindow, SW_SHOW);
 UpdateWindow(hWindow);

 listbox = CreateWindow("LISTBOX", "listbox",
  WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL,
  10, 10, 500, 200, hWindow, 0, MainInstance, NULL);

 //SendMessage(listbox, LB_ADDSTRING, 0, (LPARAM)"Test String");
}

return hWindow;
}

void ShowThreadInfo(char* id)
{
char s[80];
sprintf(s,"%s Thread ID: %08X Thread Handle: %08X",id,GetCurrentThreadId(),GetCurrentThread());
SendMessage(listbox, LB_ADDSTRING, 0, (LPARAM)s);
}

int _stdcall L1_Callback(void* quote)
{
//double bid_price;
char s[100];

ShowThreadInfo("Callback");

/*
SendMessage(listbox, LB_ADDSTRING, 0, (LPARAM)"L1 Callback");
SendMessage(listbox, LB_ADDSTRING, 0, (LPARAM)Get_secsym(quote));
bid_price = Get_l1_BidPrice(quote);
strcpy(s,"test message");
_gcvt(bid_price,8,s); // Convert float to string, 8 digits max
*/

sprintf(s,"Symbol: %s Bid Price: %g",Get_secsym(quote),Get_l1_BidPrice(quote));
SendMessage(listbox, LB_ADDSTRING, 0, (LPARAM)s);

return 0;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
MSG AMessage;
HWND hWindow;
char* user;
char* password;

MainInstance = hInstance;
CmdShow = nCmdShow;

if(Link()) return -1; // Link to DasRapper.dll

if(!WinRegister()) {
 MessageBox(0, "Register failed", NULL, MB_OK);
 return 0;
}

hWindow = WinCreate();
if(hWindow == 0) {
 MessageBox(0, "WinCreate failed", NULL, MB_OK);
 return 0;
}

ShowThreadInfo("WinMain");

ShowMainFrame();
user = "DIRECT10";
password = "demo";
Login("",user,password);
SubscribeL1("QQQQ");
SetL1Callback(L1_Callback);

while(GetMessage(&AMessage, 0, 0, 0)) {
 if(!PreTranslateMessage(&AMessage)) {
  TranslateMessage(&AMessage);
  DispatchMessage(&AMessage);
 }
}

SetL1Callback(NULL);

return AMessage.wParam;
}




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]