|
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
|
|
|
|
|
Try the code in a separate sample app then disect it.
The secret is in the ROP code. It performs a raster operation on the screen buffer directly.
Check out SetROP2
|
|
|
|
|
Thanks, that does exactly what I want for the straight line, now I'll have to figure out how to apply it to arcs.
Thanks again
DGit
|
|
|
|
|
I'm not exactly sure how the user pictures in Windows work.. But is there a way to find out the path for the current user picture so that it can be drawn into my window's DC? pure c/c++ please!
Thanks for your help!
--PerspX
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
BSoD during a Win98 presentation
|
|
|
|
|
Take a peek in this folder:
C:\Documents and Settings\All Users\Application Data\Microsoft\User Account Pictures
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello all,
I have a small but urgent problem.
I am reading a line of text from a file, that uses delimiters to
separate the text.
For that purpose I am using the strtok function. the problem is that
the text read by strtok when it finds no delimiter is of 1 char size bigger then the value it represents in the IDE.
meaning "John" is displayed as the value name holds but in strlen it shows a size of 5, as opposed to sizeof(name) that shows size of 4.
how does strtok work and why is that please, it's urgent, I have to hand it in
for school tomorow morning at 8:00 and it's now 24:00 here
the relevant code:
while( ! feof(inputFile) )
{
int check;
fgets(Line , 80 , inputFile);
command = strtok(Line , " ");
if(strcmp(command , "add_customer") == 0)
{
int i = 0;
char* name, *address;
int table_num;
if(i == 0)
{
command = strtok(NULL , ";");
name = command;
i++;
}
if(i == 1)
{
command = strtok(NULL , ";");
address = command;
i++;
}
if(i == 2)
{
command = strtok(NULL , ";");
table_num = atoi(command);
i++;
rdb_add_customer(Rest , name , address , table_num);
}
continue;
}
if(strcmp(command , "get_address") == 0)
{
int i = 0;
char* name;
if(i == 0)
{
command = strtok(NULL , ";");
name = command;
i++;
rdb_get_address(Rest , name);
}
continue;
}
//==========================================================================
int string_compare_func(Element e1 , Element e2)
{
int i , j;
if(e1 == NULL || e2 == NULL)
{
if(e1 == NULL && e2 == NULL)
return 0;
else if (e1 == NULL && e2 != NULL)
return -1;
else
return 1;
}
else
{
char* e1S = element_to_string(e1);
char* e2S = element_to_string(e2);
i = strcmp(e1S , e2S);
if(i == 0)
{
i = strlen(e2S);
return 0;
}
else if(strcmp(e1S , e2S) > 0)
{i = strlen(e1S);
i = strlen(e2S);
return 1;}
else {
i = strlen(e1S);
i = strlen(e2S);
j = sizeof(e1S);
j = sizeof(e2S);
return -1;}
}
Please HELPPPP!!!!!!!!!!!!!!
:((
}
|
|
|
|
|
sizeof and strlen are not the same thing. sizeof(e1S) is 4 because e1S is a pointer, and on your CPU, pointers are 4 bytes long.
|
|
|
|
|
Just to add a bit to what Michael said... In the post you made earlier today you had
Element string_to_element(const char* val)
{
Element localElem = malloc(sizeof(val));
strcpy((char*)localElem , val);
return localElem;
}
the sizeof( val ) is returning the size of a char pointer (4) not the length of the string. You would want to use strlen( val ) + 1 like you did in your element_to_string call.
|
|
|
|
|
Hi,
I am trying to develop a DLL which can be used in couple scenarios:
1. Loaded by a console based C++ application, with minimal Win32 code (just to load DLLs)
2. Loaded by a Windows service. This is essentially the C++ Console application converted to a service.
The issue is that I want to handle Windows Messages WM_ based. First of all I do not know whether Message Loops are possible in DLLs. In my mind there are two options:
1. Use SetWindowsHookEx - did not work - possible because the console application itself is not a windows application so does not have a message queue - not sure if my reasoning is correct.
2. Create a window in a separate thread and it may receive messages - but does it work.
So, the fundamental issues are that first I do not know that if this is even possible and second if yes, then how?
if someone can post me some code - better still point me to some authoritative source - it would be great.
Thanks for reading.
|
|
|
|
|
You don't need to have a window, but your message loop does need to run.
You can add an exported entry point to the DLL that when called, starts a thread
that runs a message loop. Note that any windows you want to create that use this message
loop to get their messages must be created on this same thread.
If you create a Win32 GUI application with the app wizard and examine the _tWinMain()
function, your thread proc in the DLL would be very similar - register any window class you
initially need, create any initial window you need, and finally, loop translating and dispatching
messages until some termination event occurs.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi-
When I open my projects and try to access the Project Property pages, the Configuration Properties window on the left is there (and browses down correctly) but the right-hand side is just a blank gray box- no grid to let me see or modify my properties.
- Happens on all my projects
- I have not used the dialogs in a long time as I have not been making those types of changes
- The projects build correctly (so the data is there and accessed correctly)
- I can see the data in the .vcproj file
- I tried updating VC++ and got one patch, but no effect
- I found one other reference to this problem (back in 2004 But no solution was given.
Can anyone help?
Thanks!
Markd
|
|
|
|
|
Hi,
Is it possible to use LPSTR_TEXTCALLBACK for some subitems in a CListCtrl control
or must it be used for every subitem ?
|
|
|
|
|
Have you tried it? I haven't....I was hoping you would try it and report
back to us with the results
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|