|
Hello,
I have to replace the occurances (which is near about 700) of a macro say ASSERT with its extended functionality say EXT_ASSERT. I can do in the following ways:
1. #define ASSERT EXT_ASSERT - but in this case if anyone want to use ASSERT he can not use it.
2. replace all the 700 occurances - replacing like this is difficult and more error prone.
Can any one tell me the better way of doing this.
Thanks and regards,
Ritesh S.
|
|
|
|
|
Ritesh wrote:
if anyone want to use ASSERT he can not use it.
what do you mean anyone ??
ASSERT is works in DEBUG mode only.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Hello! Mr. Ritesh
This question is quite interesting. I also even tried typedef but failed. But you can create a small string-based program that can read the whole file and will replace the string ASSERT with the specified word "EXT_ASSERT" simultaneously. I know its a lengthy and time-consuming procedure.
I hope there would be another way to solve this problem.
Gagan..
|
|
|
|
|
Ritesh S. wrote: replace all the 700 occurances - replacing like this is difficult and more error prone
Replacing in multiple files is less difficult if you use Edit --> Find and Replace --> Replace in Files command and specify Match case and Match whole word options.
|
|
|
|
|
I have created a modeless dialog box(suppose dlg2) and is being shown when a button is pressed in another dialogbox(dlg1).The problem is when dlg2 is o n top of all the windows i am clicking on the dlg1. It is getting activated but not comming to top of all windows. How to do this.
Please help me regarding this.
Thank You
KIRAN
|
|
|
|
|
kiran.pinjarla wrote: The problem is when dlg2 is o n top of all the windows i am clicking on the dlg1. It is getting activated but not comming to top of all windows. How to do this.
If your dlg1 is also Modeless then check how you showed the dialog which may restricts your dlg2 to come at front.
Knock out 't' from can't,
You can if you think you can
-- modified at 2:12 Tuesday 13th June, 2006
|
|
|
|
|
are you setting the style of the dialog as child.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
This may be the wrong way to do it, but you could set the parent for the second dialog to the Desktop window like GetDesktopWindow() .
this is this.
|
|
|
|
|
Use:
HWND GetActiveWindow(VOID);
and then use BringWindowToTop() function
Cheers
"Peace of mind through Technology"
|
|
|
|
|
Nish has a good work around for this problem. this one i have taken from voidnish.com
He says:
How to steal focus on 2K/XP
I bet that sometimes you long for the old days when a simple SetForegroundWindow brought your dialog into focus. Sigh! Now with 2K/XP things have sorta changed so that if you try a simple SetForegroundWindow you end up flashing the taskbar icon a few times (I never counted but something tells me it flashes thrice). Not exactly what you wanted to do, eh? Luckily there are ways to bring your dialog into the foreground.
The trick is to use AttachThreadInput to attach the thread that owns the current foreground window to our thread, then call SetForegroundWindow and then detach the attached thread, again using AttachThreadInput. Cool, huh?
AttachThreadInput(
GetWindowThreadProcessId(
::GetForegroundWindow(),NULL),
GetCurrentThreadId(),TRUE);
SetForegroundWindow();
SetFocus();
AttachThreadInput(
GetWindowThreadProcessId(
::GetForegroundWindow(),NULL),
GetCurrentThreadId(),FALSE);
SaRath.
"Don't Do Different things... Do Things Differently..."
Understanding State Pattern in C++
|
|
|
|
|
Hi,
I have used Splitter window and did a (1 row,2 cols ) split and Created Views for the Corresponding two panes. The View in the left pane has tree control in it and in the right pane has form view.
If I Click on the Items in the left pane I don't have any problem but if I
click the view in right pane and again click the left pane I am getting an exception.
CCreateContext context;
context.m_pCurrentFrame = NULL;
context.m_pCurrentDoc = GetActiveDocument();
//Getting an Exception in the above Line
context.m_pNewViewClass = NULL;
context.m_pNewDocTemplate = NULL ;
Any suggestions Please
Thanx in advance
|
|
|
|
|
In the good old days I believe people were using the arcane technology which came to be known as COM+ to embed other application's document in their own document.
Like a Word with document a Windows Media Player or Excel or Visio document inside, double click on it and *bang* you coud start edit it using Excel/WMP/Visio toolbar.
Apparently even OpenOffice could do that.
Now here is my question:
I'm a new generation programmer. Blissfully ignorant of such thing.
But I would like to know and embed Word, Excel or other kind of document in my application's own document!
How could I do that?
And is there an up-to-date technology (i.e.: .NET API) to do that?
|
|
|
|
|
i ahve one bitmap loaded in picture control with scrollbars .know what i want is when we click the bitmap and dragged it should move to corresponding co-ordinates.
for example.
in irfan view when the image is bigger then a window then mouse cursor will change his shape to hand. we drag to see the full picture
thank u in advance.
sreee
|
|
|
|
|
sree_as wrote: i ahve one bitmap loaded in picture control with scrollbars .know what i want is when we click the bitmap and dragged it should move to corresponding co-ordinates.
for example.
in irfan view when the image is bigger then a window then mouse cursor will change his shape to hand. we drag to see the full picture
thank u in advance.
You have to override OnMousemove method..track the mouse cooridates when LBUTTON is DOWN and bitblt the bitmap with the proportion of the mouse coordinates so that your bitmap will display fully.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
thank u laxman.
i intension is hwen click the lButton and drag to some point then Lbutton up then bitmap should move to corridinates how many we dragged.
thank u
sree
|
|
|
|
|
When you click down and the image is scrollable, set a flag to indicate that the mouse is down and set the capture to the window and change the cursor to the hand cursor.
When the mouse moves store the previous x y position the mouse is at. If the mouse is down you take the current position and previous position, find the offset and scroll your window appropriately.
When the mouse button goes up clear the flag to indicate the mouse is down and release the capture and set the cursor back to the arrow cursor.
|
|
|
|
|
thank u .
any sample code or any link please.
sree.
|
|
|
|
|
Exactly what problem are you facing? Depending on how you are actually doing the scrolling (setting x and y start point and invalidating the window in the OnVScroll/OnHScroll handler etc) this can't be more than a couple of lines of code.
Show what you currently have in your OnLButtonDown/OnMouseMove/OnLButtonUp handlers and then someone might help you.
-- modified at 2:55 Tuesday 13th June, 2006
|
|
|
|
|
<br />
void CImageDlg::OnLButtonDown(UINT nFlags, CPoint point) <br />
{<br />
as=true;<br />
<br />
SetScrollPos(SB_VERT,point.y,true);<br />
SetScrollPos(SB_HORZ,point.x,true);<br />
SetCapture();<br />
<br />
<br />
<br />
CDialog::OnLButtonDown(nFlags, point);<br />
}<br />
<br />
void CImageDlg::OnLButtonUp(UINT nFlags, CPoint point) <br />
{<br />
ReleaseCapture(); <br />
<br />
as=false;<br />
<br />
CDialog::OnLButtonUp(nFlags, point);<br />
}<br />
<br />
void CImageDlg::OnMouseMove(UINT nFlags, CPoint point) <br />
{<br />
<br />
<br />
if((point.x>=89&&point.x<=363)&&(point.y>=67&&point.y<=271))<br />
SetClassLong(m_hWnd,GCL_HCURSOR,(LONG)LoadCursor(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDC_CURSOR1)));<br />
else<br />
SetClassLong(m_hWnd,GCL_HCURSOR,(LONG)LoadCursor(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDC_CURSOR2)));<br />
<br />
<br />
<br />
<br />
if (as==true)<br />
{<br />
SetScrollPos(SB_HORZ,point.x,TRUE);<br />
m_bitmap.SetWindowPos(NULL,<br />
-point.x,<br />
view.top,<br />
0, 0,<br />
SWP_NOSIZE | SWP_NOZORDER);<br />
SetScrollPos(SB_VERT,point.y,TRUE);<br />
m_bitmap.SetWindowPos(NULL,<br />
view.left,<br />
-point.y,<br />
0, 0,<br />
SWP_NOSIZE | SWP_NOZORDER);<br />
}<br />
CDialog::OnMouseMove(nFlags, point);<br />
}
|
|
|
|
|
What's with all the magic numbers? What is m_bitmap and why are you using SetWindowPos? You should be writing a control that displays the bitmap and manages the scrolling by itself and this should not be part of the logic of a dialog that is containing it.
Note that point is in client coordinates and would never exceed the size of your window, so it's not particularly helpful to just set the scroll pos based on that.
void CMyBitmapView::OnMouseMove(UINT nFlags, CPoint point)
{
:
if(m_bLButtonDown==true)
{
SetScrollPos(SB_HORZ, GetScrollPos(SB_HORZ) + m_ptPrevious.x - point.x, TRUE);
SetScrollPos(SB_VERT, GetScrollPos(SB_VERT) + m_ptPrevious.y - point.y, TRUE);
}
m_ptPrevious = point;
:
}
Another note regarding cursors, if what you want is the arrow and hand cursors, use IDC_ARROW and IDC_HAND (IDC_HAND is available for Win2k/XP etc just set WINVER >= 0x0500 if you target Win9x as well then by all means add a hand cursor for that OS). I happen to use custom arrow and hand cursors in WinXP and I don't understand why devs feel the need to have their own special arrow and hand cursors for their applications.
-- modified at 4:07 Tuesday 13th June, 2006
|
|
|
|
|
thank u.sorry for disturbing u again and again.
same problem .
scrollers are moving,bitmap is not moving.
thank u in advance,
sree
|
|
|
|
|
You didn't answer any of my questions. What is m_bitmap? I can only assume that that is the window that is actually drawing the bitmap, in which case your approach is incorrect and you should be subclassing the window that is drawing the bitmap to add additional functionality. If it really is your dialog that is drawing the bitmap (which would be a rather strange design) you would have to show me your OnHScroll/OnVScroll and OnPaint handlers.
|
|
|
|
|
m_bitmap is a member varialble for our picture control where we load the picture.
void CImageDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) <br />
{<br />
int newpos = GetScrollPos(SB_HORZ);<br />
SCROLLINFO info;<br />
::ZeroMemory(&info, sizeof(info));<br />
info.cbSize = sizeof(info);<br />
info.fMask = SIF_RANGE | SIF_PAGE | SIF_POS | SIF_TRACKPOS;<br />
GetScrollInfo(SB_HORZ, &info);<br />
<br />
int low = info.nMin;<br />
int high = info.nMax - info.nPage;<br />
<br />
<br />
CRect view;<br />
GetClientRect(&view);<br />
<br />
<br />
<br />
CRect image;<br />
m_bitmap.GetWindowRect(&image);<br />
ScreenToClient(&image);<br />
<br />
<br />
switch(nSBCode)<br />
{ <br />
case SB_LINEUP:<br />
newpos -= ::GetSystemMetrics(SM_CXVSCROLL);<br />
if(newpos < low)<br />
newpos = low;<br />
break;<br />
case SB_LINEDOWN:<br />
newpos += ::GetSystemMetrics(SM_CXVSCROLL);<br />
if(newpos > high)<br />
newpos = high;<br />
break;<br />
case SB_PAGEUP:<br />
newpos -= view.Height();<br />
if(newpos < low)<br />
newpos = low;<br />
break;<br />
case SB_PAGEDOWN:<br />
newpos += view.Height();<br />
if(newpos > high)<br />
newpos = high;<br />
break;<br />
case SB_THUMBTRACK:<br />
newpos = info.nTrackPos;<br />
break;<br />
case SB_THUMBPOSITION:<br />
newpos = info.nTrackPos;<br />
break;<br />
} <br />
SetScrollPos(SB_HORZ, newpos);<br />
m_bitmap.SetWindowPos(NULL,<br />
-newpos,<br />
image.top,<br />
0, 0,<br />
SWP_NOSIZE | SWP_NOZORDER);<br />
<br />
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);<br />
}<br />
<br />
void CImageDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) <br />
{<br />
SCROLLINFO info;<br />
::ZeroMemory(&info, sizeof(info));<br />
info.cbSize = sizeof(info);<br />
info.fMask = SIF_RANGE | SIF_PAGE | SIF_POS | SIF_TRACKPOS;<br />
GetScrollInfo(SB_VERT, &info);<br />
<br />
int low = info.nMin;<br />
int high = info.nMax - info.nPage;<br />
int newpos = info.nPos;<br />
<br />
CRect view;<br />
GetClientRect(&view);<br />
<br />
<br />
CRect image;<br />
m_bitmap.GetWindowRect(&image);<br />
ScreenToClient(&image);*/<br />
switch(nSBCode)<br />
{ <br />
case SB_LINEUP:<br />
newpos -= ::GetSystemMetrics(SM_CYHSCROLL);<br />
if(newpos < low)<br />
newpos = low;<br />
break;<br />
case SB_LINEDOWN:<br />
newpos += ::GetSystemMetrics(SM_CYHSCROLL);<br />
if(newpos > high)<br />
newpos = high;<br />
break;<br />
case SB_PAGEUP:<br />
newpos -= view.Height();<br />
if(newpos < low)<br />
newpos = low;<br />
break;<br />
case SB_PAGEDOWN:<br />
newpos += view.Height();<br />
if(newpos > high)<br />
newpos = high;<br />
break;<br />
case SB_THUMBTRACK:<br />
newpos = info.nTrackPos;<br />
break;<br />
case SB_THUMBPOSITION:<br />
newpos = info.nTrackPos;<br />
break;<br />
} <br />
SetScrollPos(SB_VERT, newpos);<br />
m_bitmap.SetWindowPos(NULL,<br />
image.left,<br />
-newpos,<br />
0, 0,<br />
SWP_NOSIZE | SWP_NOZORDER);<br />
<br />
CDialog::OnVScroll(nSBCode, nPos, pScrollBar);<br />
}<br />
void CImageDlg::OnPaint() <br />
{<br />
if (IsIconic())<br />
{<br />
CPaintDC dc(this);
<br />
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);<br />
<br />
int cxIcon = GetSystemMetrics(SM_CXICON);<br />
int cyIcon = GetSystemMetrics(SM_CYICON);<br />
CRect rect;<br />
GetClientRect(&rect);<br />
int x = (rect.Width() - cxIcon + 1) / 2;<br />
int y = (rect.Height() - cyIcon + 1) / 2;<br />
<br />
dc.DrawIcon(x, y, m_hIcon);<br />
}<br />
else<br />
{<br />
CDialog::OnPaint();<br />
}<br />
}
|
|
|
|
|
I hope you realise that you have a very strange approach to your problem. The whole move the static control around thing to scroll isn't a good way of doing it and it's not particularly hard to write your own picture control that can encapsulate scrolling. Is this school work?
If you need any more functionality than this like zoom in/out etc, or you find yourself needing to reuse this scrollable picture in a different dialog, you'll see what's wrong with your current approach.
Anyway if this works for normal scrolling using your mouse (make sure you've removed those SetWindowPos() things from your OnMouseMove handler - SetScrollPos should trigger the notifications to get OnVScroll and OnHScroll called). Set breakpoints in OnVScroll and OnHScroll and start dragging and see what's different.
|
|
|
|
|
thank u iam new to vc++.actually my domain is java.
i searched the code for scrollbar and i completed this.
yes,iam reuse this scrollable picture in a different dialog.
do u ahve any example regarding this,or any code
-- modified at 5:46 Tuesday 13th June, 2006
|
|
|
|