|
Hi,
im using Wshell.Regwrite to write registry(vb script) through html page...
but it works fine only when the option "Initialize and script ActiveX
controls not marked as safe" under Tools\internet
options/Security/Customlevel/ActiveX controls and plugIns ,is set to prompt or enable .....and if we set to any other option ie(disable) it fails ie it shows error like .. "ActiveX component cannot create object "Wscript.shell"...
So May i know whether is it possible to create my own ActiveX control(signed) with certificate(using c++) and embed in my vb script so that it doesn"t depend on internet options..
if yes pls let me know how to do the same...
pls correct me if im wrong...
|
|
|
|
|
You can make an ActiveX Safe for scripting via the interfaces IObjectSafetyImpl and IObjectSafetySiteLockImpl. Search for the complicated details in the MSDN.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
I wrote an override for the OnNcPaint. It works fine, but I have a problem.
I want Windows to do the painting in a part of the NC area and let me do the painting for the remaning part.
More precisely, I want windows to draw the menu and let me do the remaining of the painting.
My ideea is to paint what I need then send a WM_NCPAINT message and a handle in wParam to the region where I want Windows to do the painting. The problem is that SendMessage drowns in some ATL code (I'm unfamiliar with ATL).
The error is about accessing an invalid address. I suppose Windows cannot access the definition of the region referred by my region handle. I think I'm supposed to do some sort of marshalling of the HRGN object, but as I said, I'm unfamiliar with ATL. Can somebody help ?
|
|
|
|
|
CString(0xcccccccc) wrote: More precisely, I want windows to draw the menu and let me do the remaining of the painting.
The way to do that is (in your WM_NCPAINT handler) to call DefWndProc, then do your painting. Don't send any extra messages or anything.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Tried this one, unsuccessfully:
::DefWindowProc(m_hWnd, WM_NCPAINT, (WPARAM) pRgn->m_hObject, pMsg->lParam);
|
|
|
|
|
If you're handling the message in a CWindowImpl derivative, you should be able to call the DefWindowProc method with no arguments to do this - here's a fragment of an ATL-based window class showing the message map and handler method:
BEGIN_MSG_MAP(CWtlsdiView)
MESSAGE_HANDLER(WM_NCPAINT, OnNcPaint)
END_MSG_MAP()
LRESULT OnNcPaint(UINT , WPARAM , LPARAM , BOOL& )
{
DefWindowProc();
return 0;
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Allowing Windows to paint the entire NC area, then painting over it will cause flickering. I need to limit the area where Windows paints by passing a region handle with the message.
|
|
|
|
|
I've had some success (I think) with this code for handling OnNcPaint:
CRect GetCaptionRect(CWindow& wnd)
{
DWORD dwStyle = wnd.GetStyle();
CSize szFrame = (dwStyle & WS_THICKFRAME) ?
CSize(GetSystemMetrics(SM_CXSIZEFRAME),
GetSystemMetrics(SM_CYSIZEFRAME)) :
CSize(GetSystemMetrics(SM_CXFIXEDFRAME),
GetSystemMetrics(SM_CYFIXEDFRAME));
int cxIcon = GetSystemMetrics(SM_CXSIZE);
CRect r;
wnd.GetWindowRect(&r);
r -= CPoint(r.left, r.top);
r.left += szFrame.cx;
r.right -= szFrame.cx;
r.top += szFrame.cy;
r.bottom = r.top + GetSystemMetrics(SM_CYCAPTION)
- GetSystemMetrics(SM_CYBORDER);
return r;
}
class MyDialog : public CDialogImpl<MyDialog>
{
public:
BEGIN_MSG_MAP(MyDialog)
MESSAGE_HANDLER(WM_NCPAINT, OnNcPaint)
END_MSG_MAP()
LRESULT OnNcPaint(UINT nMsg, WPARAM hRgn, LPARAM lParam, BOOL& )
{
CRect r = GetCaptionRect(*this);
r.right = r.left + r.Width()/2;
HRGN onlyRedrawIn = ::CreateRectRgn(r.left, r.top, r.right, r.bottom);
::DefWindowProc(m_hWnd, nMsg, (WPARAM)onlyRedrawIn, lParam);
return 0;
}
};
The trouble is (I think) that your handler sometimes gets routed around - have you read this article[^] by Paul DiLascia about custom caption bars? It talks about MFC, but is relevant to ATL and Windows in general.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
It's not the first time I see that article of Paul DiLascia. His ideeas are nice, just one problem they don't work in my implementation. Anyway, there's something wrong with the article, the author wonders about the undocumented wParam = 1 (in WM_NCPAINT), while the MSDN clearly states it stands for "entire NC area needs repainting".
As about your code, first of all thank you for your effort.
Basically you're doing what I'm doing, just my code doesn't work.
Did you test it with VS 2008 ?
I tried to browse the MFC sources, it's a brand new world, there's no more WindowProc with message loop. Lots of ATL code.
My code follows:
void CMainFrame::OnNcPaint()
{
const MSG* pMsg = GetCurrentMessage();
CRgn rgnWnd, rgnCli, rgnMenu;
int iMenuHeight = GetSystemMetrics(SM_CYMENU);
CRect rcWnd, rcCli;
GetWindowRect(&rcWnd);
CPoint ptOffset = - rcWnd.TopLeft();
rcWnd.OffsetRect(ptOffset);
GetClientRect(&rcCli);
ClientToScreen(rcCli);
rcCli.OffsetRect(ptOffset);
rcCli.top -= iMenuHeight;
rgnWnd.CreateRectRgn(rcWnd.left, rcWnd.top ,rcWnd.right ,rcWnd.bottom);
rgnCli.CreateRectRgn(rcCli.left, rcCli.top ,rcCli.right ,rcCli.bottom);
rgnWnd.CombineRgn(&rgnWnd, &rgnCli, RGN_DIFF);
rgnMenu.CreateRectRgn(rcCli.left, rcCli.top, rcCli.right, rcCli.top + iMenuHeight);
if(pMsg->wParam != 1)
{
CRgn r;
r.CreateRectRgn(0,0,0,0);
r.CopyRgn(CRgn::FromHandle((HRGN) pMsg->wParam));
r.OffsetRgn(ptOffset);
rgnWnd.CombineRgn(&rgnWnd, &r, RGN_AND);
rgnMenu.CombineRgn(&rgnMenu, &r, RGN_AND);
}
CWindowDC dc(this);
CBrush brush;
brush.CreateSolidBrush(RGB( 255, 0, 0 ));
dc.FillRgn(&rgnWnd, &brush);
CRect rcBox;
rgnMenu.GetRgnBox(&rcBox);
if(!rcBox.IsRectEmpty())
::DefWindowProc(m_hWnd, WM_NCPAINT, (WPARAM) rgnMenu.m_hObject, 0);
}
|
|
|
|
|
CString(0xcccccccc) wrote: As about your code, first of all thank you for your effort.
Basically you're doing what I'm doing, just my code doesn't work.
Did you test it with VS 2008 ?
It's the only VS I use these days...
CString(0xcccccccc) wrote: Anyway, there's something wrong with the article, the author wonders about the undocumented wParam = 1 (in WM_NCPAINT), while the MSDN clearly states it stands for "entire NC area needs repainting"
I suspect that bit of MSDN's been fixed since then - the article is 12 years old
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I solved the problem. Thank you for your help. Even though there are significant differences because I used it in an MDI application, knowing that somebody else solved the problem was really helpful.
That persuaded me to double check carefully everything. The problem was that I was calling the DefWindowProc with a region in window coordinates instead of screen coordinates. Now it works.
|
|
|
|
|
Hi, I have a custom control that I've made and I want a tooltip hover near the the mouse as move over it, and stay near the mouse, i.e. illustrating positions of the current position within the custom control.
I used the code from MSDN, but I must not be getting it quite right as its not doing anything right now, so I can't start writing code so that it follows my cursor.
So far I've added a OnMouseHover event, so when the cursor enters the area of the custom control I think I should create a tooltip. Here is what I have so far.
HWND hwndTip = CreateWindowEx(NULL, TOOLTIPS_CLASS, NULL,
WS_POPUP |TTS_ALWAYSTIP | TTS_BALLOON,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL,
NULL, NULL);
TOOLINFO toolInfo = { 0 };
toolInfo.cbSize = sizeof(toolInfo);
toolInfo.hwnd = m_hWnd;
toolInfo.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
toolInfo.uId = IDC_LINECHART1;
toolInfo.lpszText = _T("FAIL");
::SendMessage(hwndTip, TTM_ADDTOOL, 0, (LPARAM)&toolInfo);
I'm not really sure what hDlg and g_hInst is supposed to be, and how to get it,
thanks
soong
|
|
|
|
|
soongez wrote: hDlg and g_hInst
Given that those aren't used in the code you posted, do they matter?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
or you could create a small CWnd derived control to do that instead of a tooltip control ?
This signature was proudly tested on animals.
|
|
|
|
|
okay so i got tooltips to pop up, but they created repeatedly and not destroyed, so they start to build up on the screen.
I've entered the MSDN code to a OnMouseHover event of my custom control class. Should this be perhaps in my View class?
|
|
|
|
|
|
This seems so simple but I'm lost, because the web talks about SetFormat() but the class method just does not seem to exists in my C++ 6.0 version.
tried this
case WM_TIMER:
if((HWND)lParam==GetDlgItem(hwndDlg,IDC_DATETIMEPICKER4))::Set????((HDC)wParam,_T("dd-MMM-yy"));
tried this: (assertion error occurs)
// Gain a pointer to the control
CDateTimeCtrl* pCtrl = (CDateTimeCtrl*) GetDlgItem(hwndDlg,IDC_DATETIMEPICKER4);
ASSERT(pCtrl != NULL);
pCtrl->SetFormat(_T("dd-MMM-yy"));
Any ideas?
|
|
|
|
|
Don Jones BNYMellon wrote: tried this: (assertion error occurs)
What assertion error, this one?
Don Jones BNYMellon wrote: ASSERT(pCtrl != NULL);
If so that means the control( IDC_DATETIMEPICKER4) has not been created.
Aside: It is more practical when forming comparison expressions of variables to constants, to place the constant on the left side of the comparison statement NULL != pCtrl . This way the compiler will error if you typo the statement into NULL = pCtrl whereas it won't if you typo pCtrl = NULL
|
|
|
|
|
Thanks for reply
Got the date --- debug shows someting is not happy Needs the Window Handle?
// Gain a pointer to the control
char datetext[25];
EnableWindow(GetDlgItem(hwndDlg,IDC_DATETIMEPICKER4),true);
GetDlgItemText(hwndDlg,IDC_DATETIMEPICKER4,datetext,25);
CDateTimeCtrl* pCtrl = (CDateTimeCtrl*) GetDlgItem(hwndDlg,IDC_DATETIMEPICKER4);
ASSERT(pCtrl != NULL);
debug
+ datetext 0x0011f16c "4/15/2009"
+ hwndDlg 0x00050736
+ pCtrl 0x00000000 {CDateTimeCtrl hWnd=???}
|
|
|
|
|
Don Jones BNYMellon wrote: ...the web talks about SetFormat() but the class method just does not seem to exists in my C++ 6.0 version.
Have you looked in afxdtcl.h (line 50)?
Rather than force a particular format, why not use whatever Windows has been configured for?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Nice call but got another solution, so I don't have to change afxdtc.h
Here's what works.
if(cpi->eurodate!=1){
SendDlgItemMessage(hwndDlg,IDC_DATETIMEPICKER4,DTM_SETFORMAT,0,LPARAM("MM'/'dd'/'yyyy"));}
if(cpi->eurodate==1){
SendDlgItemMessage(hwndDlg,IDC_DATETIMEPICKER4,DTM_SETFORMAT,0,LPARAM("dd'/'MM'/'yyyy"));}
Thanks for all your help....
|
|
|
|
|
Don Jones BNYMellon wrote: ...so I don't have to change afxdtc.h
Nothing was ever mentioned about changing it, only to verify that the method exists.
Don Jones BNYMellon wrote: if(cpi->eurodate==1){
Why do this check if the other check evaluated to true (i.e, cpi->eurodate can't be both 1 and not 1 ).
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Sorry, you are correct and it is there... interesting... eventhou I included this header...
// Attributes
COLORREF GetMonthCalColor(int iColor) const;
COLORREF SetMonthCalColor(int iColor, COLORREF ref);
BOOL SetFormat(LPCTSTR pstrFormat);
CMonthCalCtrl* GetMonthCalCtrl() const;
CFont* GetMonthCalFont() const;
void SetMonthCalFont(HFONT hFont, BOOL bRedraw = TRUE);
|
|
|
|
|
To answer your seconrd question:
This is a 3rd party app which has a switch for EURO Date Format or NOT. I support a DLL that interfaces with another system. Yes, like you I would have used Windows configuration.
thanks again...
|
|
|
|
|
Don Jones BNYMellon wrote: This is a 3rd party app which has a switch for EURO Date Format or NOT.
I understand that, but there's still no reason to perform both if() tests when only one of them can evaluate to true. I would imagine that the compiler would realize that and perform the necessary optimization, but still.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|