|
I am working with some C++ code (not my code, of course) that has a bunch of huge functions, which I would like to refactor. Does anyone know of a utility that will scan C++ source files and report the number of lines in each function?
Jim Scott
|
|
|
|
|
I think this one[^] will do that
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Tried CCCC on a MFC program and it choked on all the special defines (macros) one is using when dealing with the win32 API.
|
|
|
|
|
You could well be right - I used it on embedded system code, and we didn't have much 'macro magic'.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks. This is a nice tool, and it gives a lot more information than I expected.
|
|
|
|
|
Here is list of SLOC metric tools:
LOC Metrics - Alternative Tools[^]
Source Monitor[^] seems to provide what you need, as it can provide a quick overview of all methods and how many statements they have. Just create a baseline and right-click the baseline and choose "Display Method Metrics...."
Also I would recommend to use Doxygen to see call hierarchies and class diagrams.
|
|
|
|
|
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=???}
|
|
|
|
|