Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 14563 Details for
Bug 14297
Add a Spinner widget to the SWT toolkit
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
win32 c code - spin button example
spin.cpp (text/plain), 4.34 KB, created by
Felipe Heidrich
on 2004-09-15 17:09:38 EDT
(
hide
)
Description:
win32 c code - spin button example
Filename:
MIME Type:
Creator:
Felipe Heidrich
Created:
2004-09-15 17:09:38 EDT
Size:
4.34 KB
patch
obsolete
> >// Windows Header Files: >#include <windows.h> >#include <commctrl.h> > >// C RunTime Header Files >#include <stdlib.h> >#include <malloc.h> >#include <memory.h> >#include <tchar.h> > >// Foward declarations of functions included in this code module: >ATOM MyRegisterClass(HINSTANCE hInstance); >BOOL InitInstance(HINSTANCE, int); >LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); >HWND hWnd, hEdit, hUpDown; > >int APIENTRY WinMain(HINSTANCE hInstance, > HINSTANCE hPrevInstance, > LPSTR lpCmdLine, > int nCmdShow) { > MSG msg; > >// InitCommonControls(); > MyRegisterClass(hInstance); > InitInstance (hInstance, nCmdShow); > > > // Main message loop: > while (GetMessage(&msg, NULL, 0, 0)) { > TranslateMessage(&msg); > DispatchMessage(&msg); > } > return msg.wParam; >} > >void showLastError (LPTSTR lpszFunction) { > TCHAR szBuf[80]; > LPVOID lpMsgBuf; > DWORD dw = GetLastError(); > > FormatMessage( > FORMAT_MESSAGE_ALLOCATE_BUFFER | > FORMAT_MESSAGE_FROM_SYSTEM, > NULL, > dw, > MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), > (LPTSTR) &lpMsgBuf, > 0, NULL ); > > wsprintf(szBuf, "%s failed with error %d %s",lpszFunction , dw, lpMsgBuf); > MessageBox(NULL, szBuf, "Error", MB_OK); > LocalFree(lpMsgBuf); > ExitProcess(dw); >} > >ATOM MyRegisterClass(HINSTANCE hInstance) { > WNDCLASS wc; > ATOM atom; > > wc.style = CS_HREDRAW | CS_VREDRAW; > wc.lpfnWndProc = (WNDPROC)WndProc; > wc.cbClsExtra = 0; > wc.cbWndExtra = 0; > wc.hInstance = hInstance; > wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); > wc.hCursor = LoadCursor(NULL, IDC_ARROW); > wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); > wc.lpszMenuName = NULL; > wc.lpszClassName = "Spinner"; > > atom = RegisterClass(&wc); > if (!atom) showLastError("RegisterClass"); > return atom; >} > >BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { > DWORD dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; > DWORD dwStyle = WS_OVERLAPPEDWINDOW; > > hWnd = CreateWindowEx( dwExStyle, // extented style > "Spinner", // class > "Spinner", // title > dwStyle, // style > CW_USEDEFAULT, 0, // x,y > CW_USEDEFAULT, 0, // width, height > NULL, // parent > NULL, // menu > hInstance, // instance > NULL); // nothing to pass to WM_CREATE > > if (!hWnd) showLastError("Init Window"); > > dwExStyle = WS_EX_CLIENTEDGE; > dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | ES_NUMBER | ES_LEFT ; > hEdit = CreateWindowEx( dwExStyle, // extented style > "EDIT", // class > 0, // title > dwStyle, // style > 10, 10, // x,y > 100, 28, // width, height > hWnd, // parent > NULL, // menu > hInstance, // instance > NULL); // nothing to pass to WM_CREATE > >// dwExStyle = 0; >// dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS; >// hUpDown = CreateWindowEx( dwExStyle, // extented style >// "UPDOWN", // class >// NULL, // title >// dwStyle, // style >// 110, 10, // x,y >// 20, 28, // width, height >// hWnd, // parent >// NULL, // menu >// hInstance, // instance >// NULL); // nothing to pass to WM_CREATE > > hUpDown = CreateUpDownControl(WS_CHILD | WS_BORDER | WS_VISIBLE, > 110, 10, 20, 28, // x y width height > hWnd, // parent > 0, // id > hInstance, // instance > hEdit, // buddy > 10, // upper limit > 0, // lower limit > 0); // pos > > > SetWindowText (hEdit, "0"); > ShowWindow(hWnd, nCmdShow); > return TRUE; >} > >LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { > > switch (message) { > case WM_NOTIFY: { > LPNMHDR pnmh = (LPNMHDR) lParam; > if (pnmh->code == UDN_DELTAPOS) { > LPNMUPDOWN lpnmud = (LPNMUPDOWN) lParam; > int value = lpnmud->iPos + lpnmud->iDelta; > int pLow, pHigh; > SendMessage (hUpDown, UDM_GETRANGE32, (WPARAM) (LPINT) &pLow, (LPARAM) (LPINT) &pHigh); > if (pLow<=value&&value<=pHigh) { > TCHAR szBuf[80]; > wsprintf(szBuf, "%d", value); > SetWindowText (hEdit, szBuf); > } > } > break; > } > case WM_DESTROY: > PostQuitMessage(0); > break; > default: > return DefWindowProc(hWnd, message, wParam, lParam); > } > return 0; >} >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 14297
:
14407
|
14561
|
14562
| 14563