本文整理汇总了C++中AwtComponent::GetHWnd方法的典型用法代码示例。如果您正苦于以下问题:C++ AwtComponent::GetHWnd方法的具体用法?C++ AwtComponent::GetHWnd怎么用?C++ AwtComponent::GetHWnd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AwtComponent
的用法示例。
在下文中一共展示了AwtComponent::GetHWnd方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VERIFY
/*
* Class: sun_awt_DefaultMouseInfoPeer
* Method: isWindowUnderMouse
* Signature: (Ljava/awt/Window)Z
*/
JNIEXPORT jboolean JNICALL
Java_sun_awt_DefaultMouseInfoPeer_isWindowUnderMouse(JNIEnv *env, jclass cls,
jobject window)
{
POINT pt;
if (env->EnsureLocalCapacity(1) < 0) {
return JNI_FALSE;
}
jobject winPeer = AwtObject::GetPeerForTarget(env, window);
PDATA pData;
pData = JNI_GET_PDATA(winPeer);
env->DeleteLocalRef(winPeer);
if (pData == NULL) {
return JNI_FALSE;
}
AwtComponent * ourWindow = (AwtComponent *)pData;
HWND hwnd = ourWindow->GetHWnd();
VERIFY(::GetCursorPos(&pt));
AwtComponent * componentFromPoint = AwtComponent::GetComponent(::WindowFromPoint(pt));
while (componentFromPoint != NULL
&& componentFromPoint->GetHWnd() != hwnd
&& !AwtComponent::IsTopLevelHWnd(componentFromPoint->GetHWnd()))
{
componentFromPoint = componentFromPoint->GetParent();
}
return ((componentFromPoint != NULL) && (componentFromPoint->GetHWnd() == hwnd)) ? JNI_TRUE : JNI_FALSE;
}
示例2: VERIFY
/*
* Class: sun_awt_windows_WCheckboxPeer
* Method: setState
* Signature: (Z)V
*/
JNIEXPORT void JNICALL
Java_sun_awt_windows_WCheckboxPeer_setState(JNIEnv *env, jobject self,
jboolean state)
{
TRY;
PDATA pData;
JNI_CHECK_PEER_RETURN(self);
AwtComponent* c = (AwtComponent*)JNI_GET_PDATA(self);
/*
* when multifont and group checkbox receive setState native
* method, it must be redraw to display correct check mark
*/
jobject target = env->GetObjectField(self, AwtObject::targetID);
jobject group = env->GetObjectField(target, AwtCheckbox::groupID);
if (group != NULL) {
HWND hWnd = c->GetHWnd();
RECT rect;
VERIFY(::GetWindowRect(hWnd,&rect));
VERIFY(::ScreenToClient(hWnd, (LPPOINT)&rect));
VERIFY(::ScreenToClient(hWnd, ((LPPOINT)&rect)+1));
VERIFY(::InvalidateRect(hWnd,&rect,TRUE));
VERIFY(::UpdateWindow(hWnd));
} else {
c->SendMessage(BM_SETCHECK, (WPARAM)(state ? BST_CHECKED :
BST_UNCHECKED));
VERIFY(::InvalidateRect(c->GetHWnd(), NULL, FALSE));
}
c->VerifyState();
CATCH_BAD_ALLOC;
}
示例3: GetObjectField
JNIEXPORT void JNICALL
Java_sun_awt_pocketpc_PPCCheckboxPeer_setState (JNIEnv *env, jobject thisObj,
jboolean state)
{
CHECK_PEER(thisObj);
AwtComponent* c = (AwtComponent*) env->GetIntField(thisObj,
WCachedIDs.PPCObjectPeer_pDataFID);
//when multifont and group checkbox receive setState native method,
//it must be redraw to display correct check mark
jobject target =
env -> GetObjectField(thisObj, WCachedIDs.PPCObjectPeer_targetFID);
if (env->CallObjectMethod(target, WCachedIDs.java_awt_Checkbox_getCheckboxGroupMID) != NULL) {
HWND hWnd = c->GetHWnd();
RECT rect;
VERIFY(::GetWindowRect(hWnd,&rect));
VERIFY(::ScreenToClient(hWnd, (LPPOINT)&rect));
VERIFY(::ScreenToClient(hWnd, ((LPPOINT)&rect)+1));
VERIFY(::InvalidateRect(hWnd,&rect,TRUE));
VERIFY(::UpdateWindow(hWnd));
} else {
c->SendMessage(BM_SETCHECK, (WPARAM)(state ? BST_CHECKED : BST_UNCHECKED));
VERIFY(::InvalidateRect(c->GetHWnd(), NULL, FALSE));
}
c->VerifyState();
}
示例4: Show
void AwtPopupMenu::Show(JNIEnv *env, jobject event, BOOL isTrayIconPopup)
{
/*
* For not TrayIcon popup.
* Convert the event's XY to absolute coordinates. The XY is
* relative to the origin component, which is passed by PopupMenu
* as the event's target.
*/
if (env->EnsureLocalCapacity(2) < 0) {
return;
}
jobject origin = (env)->GetObjectField(event, AwtEvent::targetID);
jobject peerOrigin = GetPeerForTarget(env, origin);
PDATA pData;
JNI_CHECK_PEER_GOTO(peerOrigin, done);
{
AwtComponent* awtOrigin = (AwtComponent*)pData;
POINT pt;
UINT flags = 0;
pt.x = (env)->GetIntField(event, AwtEvent::xID);
pt.y = (env)->GetIntField(event, AwtEvent::yID);
if (!isTrayIconPopup) {
::MapWindowPoints(awtOrigin->GetHWnd(), 0, (LPPOINT)&pt, 1);
// Adjust to account for the Inset values
RECT rctInsets;
awtOrigin->GetInsets(&rctInsets);
pt.x -= rctInsets.left;
pt.y -= rctInsets.top;
flags = TPM_LEFTALIGN | TPM_RIGHTBUTTON;
} else {
::SetForegroundWindow(awtOrigin->GetHWnd());
flags = TPM_NONOTIFY | TPM_RIGHTALIGN | TPM_RIGHTBUTTON | TPM_BOTTOMALIGN;
}
/* Invoke the popup. */
::TrackPopupMenu(GetHMenu(), flags, pt.x, pt.y, 0, awtOrigin->GetHWnd(), NULL);
if (isTrayIconPopup) {
::PostMessage(awtOrigin->GetHWnd(), WM_NULL, 0, 0);
}
}
done:
env->DeleteLocalRef(origin);
env->DeleteLocalRef(peerOrigin);
}
示例5: bad_alloc
/*
* Class: java_awt_AWTEvent
* Method: nativeSetSource
* Signature: (Ljava/awt/peer/ComponentPeer;)V
*/
JNIEXPORT void JNICALL Java_java_awt_AWTEvent_nativeSetSource
(JNIEnv *env, jobject self, jobject newSource)
{
TRY;
JNI_CHECK_NULL_RETURN(self, "null AWTEvent");
MSG *pMsg;
jbyteArray bdata = (jbyteArray)
env->GetObjectField(self, AwtAWTEvent::bdataID);
if (bdata != NULL) {
jboolean dummy;
PDATA pData;
JNI_CHECK_PEER_RETURN(newSource);
AwtComponent *p = (AwtComponent *)pData;
HWND hwnd = p->GetHWnd();
pMsg = (MSG *)env->GetPrimitiveArrayCritical(bdata, &dummy);
if (pMsg == NULL) {
throw std::bad_alloc();
}
pMsg->hwnd = hwnd;
env->ReleasePrimitiveArrayCritical(bdata, (void *)pMsg, 0);
}
CATCH_BAD_ALLOC;
}
示例6: DASSERT
JNIEXPORT jboolean JNICALL
Java_sun_awt_windows_WPrintDialogPeer__1show(JNIEnv *env, jobject peer)
{
TRY;
DASSERT(peer != NULL);
jobject target = env->GetObjectField(peer, AwtObject::targetID);
DASSERT(target != NULL);
jobject parent = env->GetObjectField(peer, AwtPrintDialog::parentID);
DASSERT(parent != NULL);
jobject control = env->GetObjectField(target, AwtPrintDialog::controlID);
DASSERT(control != NULL);
AwtComponent *awtParent = (AwtComponent *)JNI_GET_PDATA(parent);
DASSERT(awtParent != NULL);
PRINTDLG pd;
memset(&pd, 0, sizeof(PRINTDLG));
pd.lStructSize = sizeof(PRINTDLG);
AwtPrintControl::InitPrintDialog(env, control, pd);
pd.lpfnPrintHook = (LPPRINTHOOKPROC)PrintDialogHookProc;
pd.lpfnSetupHook = (LPSETUPHOOKPROC)PrintDialogHookProc;
pd.Flags |= PD_ENABLESETUPHOOK | PD_ENABLEPRINTHOOK;
AwtDialog::ModalDisable(NULL);
BOOL ret = AwtPrintDialog::PrintDlg(&pd);
AwtDialog::ModalEnable(NULL);
AwtDialog::ModalNextWindowToFront(awtParent->GetHWnd());
if (ret) {
AwtPrintControl::UpdateAttributes(env, control, pd);
}
return ret;
CATCH_BAD_ALLOC_RET(0);
}
示例7: Reshape
void AwtChoice::Reshape(int x, int y, int w, int h)
{
// Choice component height is fixed (when rolled up)
// so vertically center the choice in it's bounding box
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
jobject target = GetTarget(env);
jobject parent = env->GetObjectField(target, AwtComponent::parentID);
RECT rc;
int fieldHeight = GetFieldHeight();
if ((parent != NULL && env->GetObjectField(parent, AwtContainer::layoutMgrID) != NULL) &&
fieldHeight > 0 && fieldHeight < h) {
y += (h - fieldHeight) / 2;
}
/* Fix for 4783342
* Choice should ignore reshape on height changes,
* as height is dependent on Font size only.
*/
AwtComponent* awtParent = GetParent();
BOOL bReshape = true;
if (awtParent != NULL) {
::GetWindowRect(GetHWnd(), &rc);
int oldW = rc.right - rc.left;
RECT parentRc;
::GetWindowRect(awtParent->GetHWnd(), &parentRc);
int oldX = rc.left - parentRc.left;
int oldY = rc.top - parentRc.top;
bReshape = (x != oldX || y != oldY || w != oldW);
}
if (bReshape)
{
int totalHeight = GetTotalHeight();
AwtComponent::Reshape(x, y, w, totalHeight);
}
/* Bug 4255631 Solaris: Size returned by Choice.getSize() does not match
* actual size
* Fix: Set the Choice to its actual size in the component.
*/
::GetClientRect(GetHWnd(), &rc);
env->SetIntField(target, AwtComponent::widthID, (jint)rc.right);
env->SetIntField(target, AwtComponent::heightID, (jint)rc.bottom);
env->DeleteLocalRef(target);
env->DeleteLocalRef(parent);
}
示例8:
/*
* Class: sun_awt_windows_WInputMethod
* Method: disableNativeIME
* Signature: (Lsun/awt/windows/WComponentPeer;)V
*/
JNIEXPORT void JNICALL
Java_sun_awt_windows_WInputMethod_disableNativeIME(JNIEnv *env, jobject self, jobject peer)
{
TRY_NO_VERIFY;
//get C++ Class of Focused Component
if (peer == 0) return;
AwtComponent* p = (AwtComponent*)JNI_GET_PDATA(peer);
if (p == 0) return;
p->SetInputMethod(NULL, TRUE);
// use special message to call ImmAssociateContext() in main thread.
AwtToolkit::GetInstance().SendMessage(WM_AWT_ASSOCIATECONTEXT,
reinterpret_cast<WPARAM>(p->GetHWnd()), NULL);
CATCH_BAD_ALLOC;
}
示例9: VerifyState
void AwtScrollPane::VerifyState()
{
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
if (env->EnsureLocalCapacity(3) < 0) {
return;
}
if (AwtToolkit::GetInstance().VerifyComponents() == FALSE) {
return;
}
if (m_callbacksEnabled == FALSE) {
/* Component is not fully setup yet. */
return;
}
AwtComponent::VerifyState();
jobject target = AwtObject::GetTarget(env);
jobject child = JNU_CallMethodByName(env, NULL, GetPeer(env),
"getScrollSchild",
"()Ljava/awt/Component;").l;
DASSERT(!safe_ExceptionOccurred(env));
if (child != NULL) {
jobject childPeer =
(env)->GetObjectField(child, AwtComponent::peerID);
PDATA pData;
JNI_CHECK_PEER_RETURN(childPeer);
AwtComponent* awtChild = (AwtComponent *)pData;
/* Verify child window is positioned correctly. */
RECT rect, childRect;
::GetClientRect(GetHWnd(), &rect);
::MapWindowPoints(GetHWnd(), 0, (LPPOINT)&rect, 2);
::GetWindowRect(awtChild->GetHWnd(), &childRect);
DASSERT(childRect.left <= rect.left && childRect.top <= rect.top);
env->DeleteLocalRef(childPeer);
}
env->DeleteLocalRef(target);
env->DeleteLocalRef(child);
}
示例10: SUCCEEDED
/*
* Class: sun_java2d_d3d_D3DSurfaceData
* Method: initFlipBackbuffer
* Signature: (JJIZ)Z
*/
JNIEXPORT jboolean
JNICALL Java_sun_java2d_d3d_D3DSurfaceData_initFlipBackbuffer
(JNIEnv *env, jobject d3dsd, jlong pData, jlong pPeerData,
jint numBuffers, jint swapEffect,
jint vSyncType)
{
HRESULT res;
D3DSDOps *d3dsdo;
D3DContext *pCtx;
D3DPipelineManager *pMgr;
HWND hWnd;
UINT presentationInterval;
AwtComponent *pPeer;
RECT r = { 0, 0, 0, 0 };
J2dTraceLn(J2D_TRACE_INFO, "D3DSurfaceData_initFlipBackbuffer");
RETURN_STATUS_IF_NULL(d3dsdo = (D3DSDOps *)jlong_to_ptr(pData), JNI_FALSE);
RETURN_STATUS_IF_NULL(pMgr = D3DPipelineManager::GetInstance(), JNI_FALSE);
RETURN_STATUS_IF_NULL(pPeer = (AwtComponent *)jlong_to_ptr(pPeerData),
JNI_FALSE);
hWnd = pPeer->GetHWnd();
if (!IsWindow(hWnd)) {
J2dTraceLn(J2D_TRACE_WARNING,
"D3DSurfaceData_initFlipBackbuffer: disposed component");
return JNI_FALSE;
}
pPeer->GetInsets(&r);
d3dsdo->xoff = -r.left;
d3dsdo->yoff = -r.top;
if (FAILED(res = pMgr->GetD3DContext(d3dsdo->adapter, &pCtx))) {
D3DRQ_MarkLostIfNeeded(res, d3dsdo);
return JNI_FALSE;
}
RETURN_STATUS_IF_NULL(pCtx->GetResourceManager(), JNI_FALSE);
pCtx->GetResourceManager()->ReleaseResource(d3dsdo->pResource);
d3dsdo->pResource = NULL;
d3dsdo->swapEffect = (D3DSWAPEFFECT)swapEffect;
// in full-screen mode we should v-sync
if (pCtx->GetPresentationParams()->Windowed) {
if (vSyncType == VSYNC_ON) {
presentationInterval = D3DPRESENT_INTERVAL_ONE;
J2dTraceLn(J2D_TRACE_VERBOSE,
" windowed, forced interval: ONE");
} else {
presentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
J2dTraceLn(J2D_TRACE_VERBOSE,
" windowed, default interval: IMMEDIATE");
}
// REMIND: this is a workaround for the current issue
// we have with non-copy flip chains: since we can not specify
// the dest rectangle for Present for these modes, the result of
// Present(NULL, NULL) is scaled to the client area.
if (d3dsdo->xoff != 0 || d3dsdo->yoff != 0) {
d3dsdo->swapEffect = D3DSWAPEFFECT_COPY;
}
} else {
if (vSyncType == VSYNC_OFF) {
presentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
J2dTraceLn(J2D_TRACE_VERBOSE,
" full-screen, forced interval: IMMEDIATE");
} else {
presentationInterval = D3DPRESENT_INTERVAL_ONE;
J2dTraceLn(J2D_TRACE_VERBOSE,
" full-screen, default interval: ONE");
}
}
res = pCtx->GetResourceManager()->
CreateSwapChain(hWnd, numBuffers,
d3dsdo->width, d3dsdo->height,
d3dsdo->swapEffect, presentationInterval,
&d3dsdo->pResource);
if (SUCCEEDED(res)) {
J2dTraceLn1(J2D_TRACE_VERBOSE, " created swap chain pResource=0x%x",
d3dsdo->pResource);
d3dsdo->pResource->SetSDOps(d3dsdo);
} else {
D3DRQ_MarkLostIfNeeded(res, d3dsdo);
}
D3DSD_SetNativeDimensions(env, d3dsdo);
return SUCCEEDED(res);
}
示例11: Create
/* Create a new AwtScrollPane object and window. */
AwtScrollPane* AwtScrollPane::Create(jobject self, jobject parent)
{
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
jobject target = NULL;
AwtScrollPane* c = NULL;
try {
if (env->EnsureLocalCapacity(1) < 0) {
return NULL;
}
PDATA pData;
AwtComponent* awtParent;
JNI_CHECK_PEER_GOTO(parent, done);
awtParent = (AwtComponent*)pData;
JNI_CHECK_NULL_GOTO(awtParent, "null awtParent", done);
target = env->GetObjectField(self, AwtObject::targetID);
JNI_CHECK_NULL_GOTO(target, "null target", done);
c = new AwtScrollPane();
{
DWORD style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
jint scrollbarDisplayPolicy =
env->GetIntField(target, scrollbarDisplayPolicyID);
if (scrollbarDisplayPolicy
== java_awt_ScrollPane_SCROLLBARS_ALWAYS) {
style |= WS_HSCROLL | WS_VSCROLL;
}
DWORD exStyle = WS_EX_CLIENTEDGE;
if (GetRTL()) {
exStyle |= WS_EX_RIGHT | WS_EX_LEFTSCROLLBAR;
if (GetRTLReadingOrder())
exStyle |= WS_EX_RTLREADING;
}
jint x = env->GetIntField(target, AwtComponent::xID);
jint y = env->GetIntField(target, AwtComponent::yID);
jint width = env->GetIntField(target, AwtComponent::widthID);
jint height = env->GetIntField(target, AwtComponent::heightID);
c->CreateHWnd(env, L"", style, exStyle,
x, y, width, height,
awtParent->GetHWnd(),
reinterpret_cast<HMENU>(static_cast<INT_PTR>(
awtParent->CreateControlID())),
::GetSysColor(COLOR_WINDOWTEXT),
::GetSysColor(COLOR_WINDOW),
self);
}
} catch (...) {
env->DeleteLocalRef(target);
throw;
}
done:
env->DeleteLocalRef(target);
return c;
}
示例12: titleBuffer
void
AwtFileDialog::Show(void *p)
{
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
jobject peer;
WCHAR unicodeChar = L' ';
LPTSTR fileBuffer = NULL;
LPTSTR currentDirectory = NULL;
jint mode = 0;
BOOL result = FALSE;
DWORD dlgerr;
jstring directory = NULL;
jstring title = NULL;
jstring file = NULL;
jobject fileFilter = NULL;
jobject target = NULL;
jobject parent = NULL;
AwtComponent* awtParent = NULL;
jboolean multipleMode = JNI_FALSE;
OPENFILENAME ofn;
memset(&ofn, 0, sizeof(ofn));
/*
* There's a situation (see bug 4906972) when InvokeFunction (by which this method is called)
* returnes earlier than this method returnes. Probably it's caused due to ReplyMessage system call.
* So for the avoidance of this mistiming we need to make new global reference here
* (not local as it's used by the hook) and then manage it independently of the calling thread.
*/
peer = env->NewGlobalRef((jobject)p);
try {
DASSERT(peer);
target = env->GetObjectField(peer, AwtObject::targetID);
parent = env->GetObjectField(peer, AwtFileDialog::parentID);
if (parent != NULL) {
awtParent = (AwtComponent *)JNI_GET_PDATA(parent);
}
// DASSERT(awtParent);
title = (jstring)(env)->GetObjectField(target, AwtDialog::titleID);
HWND hwndOwner = awtParent ? awtParent->GetHWnd() : NULL;
if (title == NULL || env->GetStringLength(title)==0) {
title = JNU_NewStringPlatform(env, &unicodeChar);
}
JavaStringBuffer titleBuffer(env, title);
directory =
(jstring)env->GetObjectField(target, AwtFileDialog::dirID);
JavaStringBuffer directoryBuffer(env, directory);
multipleMode = env->CallBooleanMethod(peer, AwtFileDialog::isMultipleModeMID);
UINT bufferLimit;
if (multipleMode == JNI_TRUE) {
bufferLimit = MULTIPLE_MODE_BUFFER_LIMIT;
} else {
bufferLimit = SINGLE_MODE_BUFFER_LIMIT;
}
LPTSTR fileBuffer = new TCHAR[bufferLimit];
memset(fileBuffer, 0, bufferLimit * sizeof(TCHAR));
file = (jstring)env->GetObjectField(target, AwtFileDialog::fileID);
if (file != NULL) {
LPCTSTR tmp = JNU_GetStringPlatformChars(env, file, NULL);
_tcscpy(fileBuffer, tmp);
JNU_ReleaseStringPlatformChars(env, file, tmp);
} else {
fileBuffer[0] = _T('\0');
}
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFilter = s_fileFilterString;
ofn.nFilterIndex = 1;
/*
Fix for 6488834.
To disable Win32 native parent modality we have to set
hwndOwner field to either NULL or some hidden window. For
parentless dialogs we use NULL to show them in the taskbar,
and for all other dialogs AwtToolkit's HWND is used.
*/
if (awtParent != NULL)
{
ofn.hwndOwner = AwtToolkit::GetInstance().GetHWnd();
}
else
{
ofn.hwndOwner = NULL;
}
ofn.lpstrFile = fileBuffer;
ofn.nMaxFile = bufferLimit;
ofn.lpstrTitle = titleBuffer;
ofn.lpstrInitialDir = directoryBuffer;
ofn.Flags = OFN_LONGNAMES | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY |
OFN_ENABLEHOOK | OFN_EXPLORER | OFN_ENABLESIZING;
fileFilter = env->GetObjectField(peer,
AwtFileDialog::fileFilterID);
if (!JNU_IsNull(env,fileFilter)) {
ofn.Flags |= OFN_ENABLEINCLUDENOTIFY;
}
//.........这里部分代码省略.........
示例13: Create
/*
* Create a new AwtCanvas object and window.
*/
AwtCanvas* AwtCanvas::Create(jobject self, jobject hParent)
{
TRY;
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
jobject target = NULL;
AwtCanvas *canvas = NULL;
try {
if (env->EnsureLocalCapacity(1) < 0) {
return NULL;
}
AwtComponent* parent;
JNI_CHECK_NULL_GOTO(hParent, "null hParent", done);
parent = (AwtComponent*)JNI_GET_PDATA(hParent);
JNI_CHECK_NULL_GOTO(parent, "null parent", done);
target = env->GetObjectField(self, AwtObject::targetID);
JNI_CHECK_NULL_GOTO(target, "null target", done);
canvas = new AwtCanvas();
{
jint x = env->GetIntField(target, AwtComponent::xID);
jint y = env->GetIntField(target, AwtComponent::yID);
jint width = env->GetIntField(target, AwtComponent::widthID);
jint height = env->GetIntField(target, AwtComponent::heightID);
canvas->CreateHWnd(env, L"",
WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0,
x, y, width, height,
parent->GetHWnd(),
NULL,
::GetSysColor(COLOR_WINDOWTEXT),
::GetSysColor(COLOR_WINDOW),
self);
// Set the pixel format of the HWND if a GraphicsConfiguration
// was provided to the Canvas constructor.
jclass canvasClass = env->FindClass("java/awt/Canvas");
if ( env->IsInstanceOf( target, canvasClass ) ) {
// Get GraphicsConfig from our target
jobject graphicsConfig = env->GetObjectField(target,
AwtComponent::graphicsConfigID);
if (graphicsConfig != NULL) {
jclass win32cls = env->FindClass("sun/awt/Win32GraphicsConfig");
DASSERT (win32cls != NULL);
if ( env->IsInstanceOf( graphicsConfig, win32cls ) ) {
// Get the visual ID member from our GC
jint visual = env->GetIntField(graphicsConfig,
AwtWin32GraphicsConfig::win32GCVisualID);
if (visual > 0) {
HDC hdc = ::GetDC(canvas->m_hwnd);
// Set our pixel format
PIXELFORMATDESCRIPTOR pfd;
BOOL ret = ::SetPixelFormat(hdc, (int)visual, &pfd);
::ReleaseDC(canvas->m_hwnd, hdc);
//Since a GraphicsConfiguration was specified, we should
//throw an exception if the PixelFormat couldn't be set.
if (ret == FALSE) {
DASSERT(!safe_ExceptionOccurred(env));
jclass excCls = env->FindClass(
"java/lang/RuntimeException");
DASSERT(excCls);
env->ExceptionClear();
env->ThrowNew(excCls,
"\nUnable to set Pixel format on Canvas");
env->DeleteLocalRef(target);
return canvas;
}
}
}
}
}
}
} catch (...) {
env->DeleteLocalRef(target);
throw;
}
done:
env->DeleteLocalRef(target);
return canvas;
CATCH_BAD_ALLOC_RET(0);
}
示例14: DASSERT
JNIEXPORT jboolean JNICALL
Java_sun_awt_windows_WPrintDialogPeer__1show(JNIEnv *env, jobject peer)
{
TRY;
jboolean result = JNI_FALSE;
// as peer object is used later on another thread, create a global ref
jobject peerGlobalRef = env->NewGlobalRef(peer);
DASSERT(peerGlobalRef != NULL);
jobject target = env->GetObjectField(peerGlobalRef, AwtObject::targetID);
DASSERT(target != NULL);
jobject parent = env->GetObjectField(peerGlobalRef, AwtPrintDialog::parentID);
jobject control = env->GetObjectField(target, AwtPrintDialog::controlID);
DASSERT(control != NULL);
AwtComponent *awtParent = (parent != NULL) ? (AwtComponent *)JNI_GET_PDATA(parent) : NULL;
HWND hwndOwner = awtParent ? awtParent->GetHWnd() : NULL;
PRINTDLG pd;
memset(&pd, 0, sizeof(PRINTDLG));
pd.lStructSize = sizeof(PRINTDLG);
pd.lCustData = (LPARAM)peerGlobalRef;
if (!AwtPrintControl::InitPrintDialog(env, control, pd))
{
result = JNI_FALSE;
}
else
{
pd.lpfnPrintHook = (LPPRINTHOOKPROC)PrintDialogHookProc;
pd.lpfnSetupHook = (LPSETUPHOOKPROC)PrintDialogHookProc;
pd.Flags |= PD_ENABLESETUPHOOK | PD_ENABLEPRINTHOOK;
// To disable Win32 native parent modality we have to set
// hwndOwner field to either NULL or some hidden window. For
// parentless dialogs we use NULL to show them in the taskbar,
// and for all other dialogs AwtToolkit's HWND is used.
if (awtParent != NULL) {
pd.hwndOwner = AwtToolkit::GetInstance().GetHWnd();
} else {
pd.hwndOwner = NULL;
}
AwtDialog::CheckInstallModalHook();
BOOL ret = AwtPrintDialog::PrintDlg(&pd);
if (ret)
{
AwtPrintControl::UpdateAttributes(env, control, pd);
result = JNI_TRUE;
}
else
{
result = JNI_FALSE;
}
DASSERT(env->GetLongField(peer, AwtComponent::hwndID) == 0L);
AwtDialog::CheckUninstallModalHook();
AwtDialog::ModalActivateNextWindow(NULL, target, peer);
}
env->DeleteGlobalRef(peerGlobalRef);
env->DeleteLocalRef(target);
if (parent != NULL) {
env->DeleteLocalRef(parent);
}
env->DeleteLocalRef(control);
return result;
CATCH_BAD_ALLOC_RET(0);
}
示例15: InitPrintDialog
/*
* Copy settings into a print dialog & any devmode
*/
BOOL AwtPrintControl::InitPrintDialog(JNIEnv *env,
jobject printCtrl, PRINTDLG &pd) {
HWND hwndOwner = NULL;
jobject dialogOwner =
env->GetObjectField(printCtrl, AwtPrintControl::dialogOwnerPeerID);
if (dialogOwner != NULL) {
AwtComponent *dialogOwnerComp =
(AwtComponent *)JNI_GET_PDATA(dialogOwner);
hwndOwner = dialogOwnerComp->GetHWnd();
env->DeleteLocalRef(dialogOwner);
dialogOwner = NULL;
}
jobject mdh = NULL;
jobject dest = NULL;
jobject select = NULL;
jobject dialog = NULL;
LPTSTR printName = NULL;
LPTSTR portName = NULL;
// If the user didn't specify a printer, then this call returns the
// name of the default printer.
jstring printerName = (jstring)
env->CallObjectMethod(printCtrl, AwtPrintControl::getPrinterID);
if (printerName != NULL) {
pd.hDevMode = AwtPrintControl::getPrintHDMode(env, printCtrl);
pd.hDevNames = AwtPrintControl::getPrintHDName(env, printCtrl);
LPTSTR getName = (LPTSTR)JNU_GetStringPlatformChars(env,
printerName, NULL);
BOOL samePrinter = FALSE;
// check if given printername is same as the currently saved printer
if (pd.hDevNames != NULL ) {
DEVNAMES *devnames = (DEVNAMES *)::GlobalLock(pd.hDevNames);
if (devnames != NULL) {
LPTSTR lpdevnames = (LPTSTR)devnames;
printName = lpdevnames+devnames->wDeviceOffset;
if (!_tcscmp(printName, getName)) {
samePrinter = TRUE;
printName = _tcsdup(lpdevnames+devnames->wDeviceOffset);
portName = _tcsdup(lpdevnames+devnames->wOutputOffset);
}
}
::GlobalUnlock(pd.hDevNames);
}
if (!samePrinter) {
LPTSTR foundPrinter = NULL;
LPTSTR foundPort = NULL;
DWORD cbBuf = 0;
VERIFY(AwtPrintControl::FindPrinter(NULL, NULL, &cbBuf,
NULL, NULL));
LPBYTE buffer = new BYTE[cbBuf];
if (AwtPrintControl::FindPrinter(printerName, buffer, &cbBuf,
&foundPrinter, &foundPort) &&
(foundPrinter != NULL) && (foundPort != NULL)) {
printName = _tcsdup(foundPrinter);
portName = _tcsdup(foundPort);
if (!AwtPrintControl::CreateDevModeAndDevNames(&pd,
foundPrinter, foundPort)) {
delete [] buffer;
if (printName != NULL) {
free(printName);
}
if (portName != NULL) {
free(portName);
}
return FALSE;
}
DASSERT(pd.hDevNames != NULL);
} else {
delete [] buffer;
if (printName != NULL) {
free(printName);
}
if (portName != NULL) {
free(portName);
}
return FALSE;
}
delete [] buffer;
}
// PrintDlg may change the values of hDevMode and hDevNames so we
// re-initialize our saved handles.
//.........这里部分代码省略.........