|
Hi all. I am feeling very stupid. I cannot find any article/sample code showing me how to do a simple thing like using a CStatic groupbox in Visual C++ 2005. I am adding controls on top of a groupbox in the designer, but when running the application, the groupbox hides all the controls. MSDN is (as usual) of very little help. Anyone able to show me how to see the controls? When disabling/enabling the groupbox, how do you automatically disable/enable the controls inside it? Thank you.
|
|
|
|
|
You may have to set the groupbox control's Transparent property to true.
If the problem is Z-order, you can use Format/Tab Order (ctrl-D) and set the order of the controls,
making the groupbox earlier in the tab order than the controls within it.
Enabling and disabling the controls within the group box is done the same as with any other controls.
The groupbox is just a static control so it doesn't give you any special features for
working with the controls within the groupbox.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi
I have written a utility program using c++ that does some number crunching. To give access to the users, created a dll by wrapping member functions of this c++ class. I have successfully compiled (using VS2005) and used the dll.
Now I would like to make it available to public. However, the users of the dll may want to use it with differnt compilers (other than VS2005) such as VB, Borland C++, or Delphi.
What is the best way to generate .lib, .h, .pas (delphi), etc files. Any guidence please.
Regards,
Prasad
|
|
|
|
|
T.D.Prasad wrote: However, the users of the dll may want to use it with differnt compilers (other than VS2005) such as VB, Borland C++, or Delphi.
COM was invented specifically for this purpose.
|
|
|
|
|
Thanks for the suggestion. However, the user of the dll may not have sufficient knwledge to use a com object. In the help file I am giving instructions on how to use dll with VC++, BC++, VB etc. (FYI: I do not know how to use a com object, the users of dll are civil engineers)
Please answer my earlier question, if anyone can.
Regards,
Prasad
|
|
|
|
|
T.D.Prasad wrote: What is the best way to generate .lib, .h, .pas (delphi), etc files. Any guidence please.
It seems to be Win32 dll which are exposing Functions .. Right! com is best method for doing so.. but as you have said that, the enduser doesn't know hows to use COM.
I havn't worked in Delpi and borland C++, so don't how to call dll there.. but VB has the support for win32 dll. like if we need Sleep function of Kernel32.dll in VB.. we use this decalaration to get it
Public Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)
you have to do same for evrything
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
1.by people's habits, a week should start from sunday or monday?
2.the start day should be 1 or 0 for general users? - i think 0 is possible incorrect because they are not C programmers familar with 0 as first one.
|
|
|
|
|
includeh10 wrote: 1.by people's habits, a week should start from sunday or monday?
Monday, since Saturday and Sunday occur on the weekend.
includeh10 wrote: 2.the start day should be 1 or 0 for general users? - i think 0 is possible incorrect because they are not C programmers familar with 0 as first one.
Zero based is just a mindset we all have around here. VB programmers that I know like ones based indexing and their more like normal people than we are so I'd say start at one.
Just my two cents.
|
|
|
|
|
1) I prefere to start from monday
2) I think that start from 0 for many users can't be the right solution, I think that they prefere 1
Is there also possible to indicate the weeknumber using 3 chars according with his name: from 'Mon' (monday) to 'Sun' (sunday)
It is more elegant ...
Russell
|
|
|
|
|
1 - this depends on the locale, some people say Sunday, some say Monday.
2 - you're obviously right, users want 1 based.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
1. is highly culture specific and set in the windows locale settings. You should honor that setting.
strftime() has sunday as 0.
2. You should not display numbers to the users. Display the names, maybe abbreviated. This way, no one will ever see if you start with 0 or with 1.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
How can I use SQL operation such as create database ,delete database ,update database, change password, add user.....
by write the code in visual c++.
Please give me the good link or article which support this issue.
Thanks
|
|
|
|
|
Your keywords are ADO, DAO and ODBC. I believe ADO was the newest, certainly the .NET one is called ADO.NET.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
In addition to Christian's reply...
DAO is deprecated - it's not recommended as a solution any more.
You can also add "OLE DB" (and "ADO" without the .NET) to the list of keywords.
This article has info on some of the possible data access methods available from
Microsoft: Data Access Technologies Road Map[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
What's the best way to determine if this runtime is installed?
|
|
|
|
|
Go to the Control Panel and open "Add or Remove Programs" and should be under "Microsoft Visual Studio ..."!
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
I meant programmatically determining if it's installed.
-- modified at 22:46 Saturday 8th September, 2007
Nevermind. I found it:
1. Call the MsiQueryProductState API
2. Pass in the product code {7299052b-02a4-4627-81f2-1818da5d550d} for the x86 package, {071c9b48-7c32-4621-a0ac-3f809523288f} for the x64 package or {0f8fb34e-675e-42ed-850b-29d98c2ece08} for the ia64 package
3. Check the return value of this API. If it is anything other than INSTALLSTATE_DEFAULT, the package is not yet installed
|
|
|
|
|
First a little background:
I'm an experienced programmer but not in Windows, I've written a number of dialog based Windows programs that run just fine so I'm familiar with some Windows and MFC concepts but not all. I'm trying to write a Windows program based on the example program Scribble that comes with the version of Windows I'm using (Visual C++ 6) and have run into a problem with the document view construct particularly the View.
What I want to do is draw a straight line or a smooth arc starting where I start holding the left mouse button down and have it end where I release the mouse button. If I move the mouse in random jerks while holding the button down I want the line on the screen to remain a straight line (or smooth Arc) from the origin to the current location of the mouse pointer. The best I've been able to do so far either makes the line flash mostly off or show as whole bunch of lines while I move the mouse. If I force the window to redraw then the excess lines vanish and the desired one remains. I would also like to be able to select the line or arc (after it's drawn) and move or rotate it.
Can someone point me to an example of how to code this? (Visio does what I want).
Thanks
|
|
|
|
|
What you want to do is, instead of what scribble does ( create a line from the last mouse position to where it is, then make the current position the 'last' position for the next mouse event ), you want to remember the point where your mouse went down, and keep updating a single line from that static starting point to the current end point. If you want to draw an arc, I believe you need to establish a third point programatically, that will then establish the arc that starts and ends that those points you established with the mouse.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
That's what I'm doing but that causes the flashing and or multiple line on screen. If I just remember the starting point and use the LineTo function on button release it will result in the line where and as I want it but it doesn't give the user feedback while moving the mouse which is what I want. The Elipse function will work for arcs in a similar way but again the feedback is missing.
DGit
|
|
|
|
|
DGit wrote: but that causes the flashing and or multiple line on screen
You need to build double buffering into your application. Multiple lines would be a bug.
You need to call Invalidate(false) to force a redraw, make sure that WM_ERASEBACKGROUND is not doing anything, and perhaps build a double buffer.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: You need to build double buffering into your application
For rubberbanding?
Christian Graus wrote: You need to call Invalidate(false) to force a redraw
Invalidating the entire client area for something a ROP would achieve seems a bit excessive. Maybe I'm misunderstanding what they are trying to accomplish.
I took it as the OP was not using SetRop2 before drawing the graphics primitive and thus was not erasing the old line or arc.
|
|
|
|
|
Christian:
As I said before I'm not a Windows programmer so I'm not sure how I would go about double buffering a line draw instruction. Also I've tried invalidating the rectangle containing the old line but I think that's what's causing the flashing. Any more detailed help will be greatly appreciated.
Thanks
DGit
|
|
|
|
|
Rubberbanding the line is just part of what you need. Once you finish tracking the line and release the mouse button, your OnPaint or OnDraw will need to keep redrawing the graphics primitives (lines, arcs, ellipses, rects, etc...) whenever the area you've drawn to is invalidated.
Ivor Horton has a great introduction to this in his Visual C++ books. He goes through what is needed to store the coordinates of graphics primitives in the document in collection classes etc...
But, with that disclaimer aside, here's a quick and dirty demo on how to rubberband a line (remember, this only cover the rubberbanding and not redrawing your window when you drag another window over it etc...)...
Start a new Visual C++ Doc/View project, nothing fancy using a single document and deriving from CView for simplicity.
Use the ClassWizard to add these handlers to your view class and ensure the code looks something like this...
// in your views .h file
private:
void DrawRubberBand(CPoint pointCurrent);
CPoint m_pointLast;
CPoint m_pointStart;
BOOL m_bTracking;
// in your views .cpp file
void CRubberBandView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if (nFlags & MK_LBUTTON) {
DrawRubberBand(point);
m_bTracking=TRUE;
m_pointLast=point;
}
CView::OnMouseMove(nFlags, point);
}
void CRubberBandView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
SetCapture();
m_pointStart=point;
m_pointLast=point;
CView::OnLButtonDown(nFlags, point);
}
void CRubberBandView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
ReleaseCapture();
m_bTracking=FALSE;
DrawRubberBand(point); // Erase the last line
CView::OnLButtonUp(nFlags, point);
}
void CRubberBandView::DrawRubberBand(CPoint pointCurrent)
{
CClientDC dc(this);
dc.SetROP2(R2_NOT);
dc.SelectStockObject(BLACK_PEN);
// Do we need to erase last line
if (m_bTracking) {
dc.MoveTo(m_pointStart);
dc.LineTo(m_pointLast);
}
// Draw the current line
dc.MoveTo(m_pointStart);
dc.LineTo(pointCurrent);
}
-- modified at 23:14 Saturday 8th September, 2007
|
|
|
|
|
That's roughly what I've been trying to do but looking at your DrawRubberBand() function I don't see how:
if (m_bTracking) {
dc.MoveTo(m_pointStart);
dc.LineTo(m_pointLast);
}
erases the previous line. I've tried invalidating the rectangle containing the previous line and drawing the new one but that just causes flashing on the screen and an occasional part of the new line.
DGit
|
|
|
|