|
I want to open and edit a Microsoft Access 2000 (mdb) file by using the CDatabase and CRecordset classes in Microsoft Visual C++ 6.0.
I open the database using the following command:
db.Open(_T(""), FALSE, FALSE, "ODBC;DSN=MY_DSN");
Now I want to open the table "MyTable" from the database, how should I do this?
I tried the following code, but it threw me an exception at file "dbcore.cpp" at line 66.
CRecordset rs(&db);
rs.Open(CRecordset::dynaset,"MyTable",CRecordset::none);
Does anyone know why this error occured and how can I open that table correctly?
Thanks in advance
|
|
|
|
|
Hello everyone,
I'm still struggling with my classes hierarchy. Now, what I have is pure abstract interfaces classes and correspondent to them objects classes, which are actually hidden inside dll.
API.h
<br />
class __declspec(dllexport/dllimport) CxID {<br />
public:<br />
static const int GetID();<br />
private:<br />
static int iID;<br />
};<br />
class IxA {<br />
virtual int GetA() = 0;<br />
};<br />
class IxB_Only {<br />
virtual int GetB() = 0;<br />
};<br />
class IxB: public IxA, public IxB_Only {<br />
};<br />
<br />
extern __declspec(dllexport/dllimport) IxB *GetObject();
DLL.h
<br />
#include "API.h"<br />
class CxA: public CxID, public IxA {<br />
public:<br />
int GetA() { return 0xAA; }<br />
private:<br />
ID m_ID;<br />
};<br />
class CxB: public CxA, public IxB_Only {<br />
int GetB() { return 0xBB; }<br />
};<br />
DLL.cpp
<br />
CxB *g_pObj;<br />
BOOL APIENTRY DllMain(...) {<br />
...<br />
case DLL_PROCESS_ATTACH:<br />
g_pObj = new CxB();<br />
break;<br />
...<br />
}<br />
<br />
__declspec(dllexport/dllimport) IxB *GetObject() {<br />
return (IxB*)g_pObj;<br />
};<br />
Now, in application:
<br />
IxB *pObj = GetObj();<br />
So, what I want to achive by doing that is to be able to cast B object, which is hidded in dll and not known to user, to public ifaces iB and iA.
But, I have a problem. (Sorry for such long introduction)
When I debug my app I see this:
pObj
|--[CxB]
| |--CxA
| | |--IxA __vfptr with good address and fuctions
| |--IxB_Only __vfptr with good address and functions
|--IxA __vfptr with good address and functions
|--IxB_Only __vfptr with... 0xcdcdcdcd and error CXX0030: expression cannot be evaluated
It's obvious when I do pObj->GetB() I get "Access violation".
I have no idea what is wrong. It must work, I know it. But I can't see the flaw.
Please, plase, plase, somebody, any clue?
Thanks in advance.
|
|
|
|
|
Is it possible that the problem lies within your constructors ?
|
|
|
|
|
Hail Darkbyte,
No, simply because I don't have anything in C-tors except zeroing a couple of integers.
Thanks for the answer though.
|
|
|
|
|
Salam From Hafiz
Serial Port Communication is my
interresting topic,I want to
work at it if some one know
about it tell me to create
(establish) serial connection
thanks From Hafiz
|
|
|
|
|
Hain buddy,
just Search CSerialPort Class in Codeproject,that will really help you in you cause.
khuda hafiz
-----------------------------
"I Think It will Work"
Formerly Known As "Alok The Programmer" at CP
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Check out MSDN.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnfiles/html/msdn_serial.asp
Kuphryn
|
|
|
|
|
I am doing realtime video manipulation software... so far, I am capturing frame from a camera, saving it to a disk and then retriveing it, converting to array of integers, and then do the manipulation.
Here I get about 2fps which is not acceptable.
Is there way to grab a frame and point where the image is the RAM and change pixels there?
in VC++ or VB6
thanks
|
|
|
|
|
More information on what you are using would help people answer the question.
The solution depends on how you are grabbing the image.
I have used Imagenation and National Instruments frame grabber cards - both of these come with sample applications in VC++ / VB, which let you allocate frame buffers in main memory, capture images to these buffers, access and process the image, and display the frame.
|
|
|
|
|
thanks for the reply...
I want to be able to use WDM (i think it's called that way) so I can use any camera. Currently I am using it with video in on Elsa Erasor 3 graphic card and with some cheap webcams...
I'm not sure how that really works but in my head I am supposed to find out address of the frame buffer in memory and take each captured pixel, change RGB value and put it back...
|
|
|
|
|
Sorry - my experience was using drivers which came with grabber cards, not WDM drivers. I wish I could help you!
|
|
|
|
|
thanks anyway...
Ive foung cFrameGrabber ehich is supposed to be a warper for AviCap which manipulates image directly in memory... the example application is so huge and complicated and maybe only 2fps faster then in Visual Basic with saving to file...
I guess I will wait a few years till computers gets stronger
|
|
|
|
|
Well the printing is dangerous task i do not know why in MFC. I am in fix for this problem.
Problem Statement:
1.0 If i am using default mapping mode i.e. MM_TEXT or explicitly mentioning
mapping mode as MM_TEXT here then circle is drawn on view. But on the
Print Previewing the image turns out to be microscopic.
2.0 If i am using mapping mode MM_LOENGLISH, then on menu item clicking it
draws but on OnDraw it doesnot shows again. and every thing is
blank. Even in print preview.
I had attaching sample code and application on the codeguru forum which illustrates the problem.
http://www.codeguru.com/forum/showthread.php?t=304420
Leave your mark wherever you go
|
|
|
|
|
Salam
If any One Know about Dialog Box Controlls Send me (easy,Begginners) Information Or Programms
|
|
|
|
|
You'll have to be a bit more specific about which controls but there are lots ot tutorials for beginnners here[^]
Michael
CP Blog [^]
|
|
|
|
|
The VMR-based sample code is completely valid.
The VMR-7 Filter is only supported in Windows XP, however, the VMR-9 (Video Mixing Renderer Filter 9) is available in all platforms supported by DirectX 9. So, go ahead and use the VMR-based sample code in the documentation. Just refer to the VMR-9 reference for correct interfaces/function calls.
Because VMR-9 is not the default renderer, you must manually add it to the end of the filter chain by using IFilterGraph::AddFilter method. This means that you cannot use any pre-configured rendering functions, but must build and connect the entire filter graph yourself. This is a tad more difficult, but have no fear, the DirectX C++ documentation has examples to building complex filter graphs, too.
For a quick link, here's a topic you should search for in the DirectX C++ documentation "Building a VMR-9 Filter Graph". It can be found from "DirectShow -> Using DirectShow -> Using the Video Mixing Renderer -> Building a VMR-9 Filter Graph".
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Antti,
I guess I misunderstood the symptoms. I suspect that either the display or the capture card device driver, or both, are not supporting VMR-9. I am having a lot of difficulty locating drivers for the hardware with support for DirectX 9.0 and VMR, so do you know of a pre-DirectX 7.0 way of doing this efficiently... Perhaps by performing the drawing of the overlay filter with the application in some way?
|
|
|
|
|
The final option on this scenario is to use the Overlay Mixer Filter and a Video Renderer. These two filters must again be added and connected manually.
The steps required to use them:
1. Create a filter graph object, and query for IGraphBuilder and IFilterGraph interfaces on the object
2. Add a source file filter using IGraphBuilder::AddSourceFilter and save the IBaseFilter pointer
3. Create the Overlay Mixer Filter object (CLSID_OverlayMixer) and query for it's IBaseFilter interface. Add this filter into the filter chain using IFilterGraph::AddFilter
4. Create the Video Renderer object (CLSID_VideoRenderer), repeating the steps in #3.
Now it's time to connect the filter chain pins. Firstly, on the source filter's IBaseFilter interface, call IBaseFilter::EnumPins to get an enumeration of the available pins. See the DirectX C++ Documentation with topic "Enumerating Pins" to get sample code on how to enumerate available pins. Get the first pin and save the IPin interface pointer.
Next, get the Overlay Mixer Filter object's IBaseFilter interface, and query for the pin at ID 0. Get this pin's IPin interface. Now, you use the Filter Graph object's IFilterGraph::Connect to connect these two pins. If any extra pins are required to connect these two, they are added and connected automatically. If the connection fails, query for the next pin in the source filter, and again attempt to connect. When a suitable configuration is found, the method will succeed. Remember to release all unnecessary IPin pointers, and the enumeration pointers when done.
Repeat the steps to connect the Overlay Mixer Filter's output (MEDIATYPE_Overlay) into the Video Renderer Filter's input. The reason why you cannot directly connect from the source filter into the Video Renderer is the fact that the Overlay Mixer Filter would be skipped. Hence the dual-step process.
When done, you need to configure the Video Renderer Filter to display the video in a correct window. For this purpose, query for IVideoWindow interface on the Filter Graph object. Now the filter graph is ready to run, so query for IMediaControl interface and issue IMediaControl::Run . The video is displayed in the window you specified.
If you want to test whether using a certain filter chain will work, you can use the GraphEdit tool that ships with DirectX SDK. This tool allows you to build even complex filter graphs that support video, audio or both. It even allows you to create a video capture graph if necessary.
Unfortunately I don't have any prepared source code. If you need any, let me know and I'll see to it if I can fathom up some simple example for you.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Additionally, if you need to add an image overlay (e.g. a logo) to the video, see this link[^].
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
I am stuck in a Windows 98 environment with a Direct X capture card. I need to overlay graphics onto the video stream at screen-resolution as the video is being previewed to the display. Because I am stuck with Win98, all the VMR-based sample code that comes with DirectX 9.0 SDK is useless to me.
Can anybody give me any advice / sample code on how to achieve this?
Thank you,
Pieter Smith
|
|
|
|
|
If you spy Calc.exe on Windows 2003 you find that all of the buttons are BS_PUSHBUTTON style. But the text on the buttons is coloured. How is this possible.
My understanding is that to add any colour to a button you need to make it owner draw and handle the CTLCOLOR_BTN message.
Alternatively, is the source code for calc.exe available ? And, where can I get hold of it.
Many thanks
Jonathan
jonathanappswing at hotmail dot com
|
|
|
|
|
harropj wrote:
My understanding is that to add any colour to a button you need to make it owner draw and handle the CTLCOLOR_BTN message.
Not entirely so. You can use the BS_PUSHBUTTON style to indicate how the button responds to a mouse click. However, you can also override the WM_PAINT message handler to modify the way the button is drawn.
This approach is somewhat of a semi-owner drawn button, where Windows OS default behaviour is used to the maximum extent, and only where required, the default behaviour is overridden.
Unfortunately I don't know if there's source code available for Calc.exe. In Windows 2003, I also believe that the calculator is implemented by using C# or other .Net Framework language (such as C++/CLI). The .Net Framework offers many, many improvements over standard Windows or MFC approach procedures. When looking at the .Net Documentation, you can see that there is a Button class in System.Windows.Forms namespace. This class has a property called ForeColor that depicts the button's text color.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
i have written an application which i start at boot time. now, when the system is shut down, i don't do anything explicitly in my application. i know, when the system goes down, it sends WM_QUERYENDSESSION message and when all the application returns a non-zero value, it sends a WM_ENDSESSION message. Now, how do i handle this message in my dailog based application. I need to handle this message coz i need to change a registry entry when the system shuts down. the classwizard does not show the handling of such message.
pliz help.
|
|
|
|
|
You'll have to manually add the ON_WM_ENDSESSION() entry to the message map and add a void OnEndSession(BOOL bEnding) function to handle the message.
Michael
CP Blog [^]
|
|
|
|
|
hi Michael,
i manually added the ON_WM_ENDSESSION() and in the OnEndSession(BOOL bEnding) function did the necessary regitry changes. Now, the application responds to shutdown. but it also responds when i log off. i do not want my application to make any registry changes when i just log off. how do i differentiate between 'SHUT DOWN' and 'LOG OFF'. should i handle WM_QUERYENDSESSION messge instead of WM_ENDSESSION.
|
|
|
|