|
You are absolutely right!
I tried to change my vb variable holding the object to a global instance, and it worked like a charm!
Apparently Visual Basic dereferences the interface pointer when leaving scope.
Thanks for helping me out
Christian Skovdal Andersen
|
|
|
|
|
I have experienced similar problems due to the type casting back to your class not resulting in the correct vtable.
The class I passed had multiple inheritence. In order to fix the problem, I first had to cast the LPVOID to the base class, and then once again cast that resulting pointer into the desired class.
Anyhow, that is what worked for me.
|
|
|
|
|
I'm creating a Connection like this:
m_Connection.CreateInstance(__uuidof(Connection));
CComBSTR conStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=";
conStr.Append(DatabasePath);
bstr_t con(conStr);
TESTHR(m_Connection->Open(con, "", "", adConnectUnspecified));
and then trying this in another method:
if (m_Connection == NULL)
return S_FALSE;
_RecordsetPtr records = NULL;
records.CreateInstance(__uuidof(Recordset));
try
{
VARIANT v;
m_Connection->Execute(L"Select * FROM File Database", &v, 0);
records->Open("Select * FROM File Database", _variant_t((IDispatch*)m_Connection, true),
adOpenDynamic, adLockOptimistic, adCmdTable);
}
catch(_com_error & e)
{
MessageBox(NULL, e.ErrorMessage(), "", 0);
}
Both the m_Connection->Execute call and the records->Open call result in an error message:
IDispatch Error #3092
that is to say, if I comment out the former, the latter does the same thing.
I've search MSDN for 3092, and found nothing useful. I am using W2000 if that helps. Any suggestions recieved with much rejoicing...
Christian
Secrets of a happy marriage #27:
Never go to bed if you are mad at each other. It's more fun to stay up and fight.
|
|
|
|
|
The Error Lookup util says 3092 means "There is no account for this computer in the security database." HTH
--Mike--
http://home.inreach.com/mdunn/
A recent survey reports that 1/4 of all internet users in England surf for porn.
The other 3/4 just didn't want to admit it.
|
|
|
|
|
What does that mean ? I foudn that error number in MSDN, but found something different, so I thought that may be it - does it mean under Win2000 I need to provide a username/[assword combination for any database I use ?
Christian
Secrets of a happy marriage #27:
Never go to bed if you are mad at each other. It's more fun to stay up and fight.
|
|
|
|
|
I need to create an application.
and I need that MyApp will recieve all WM_KEYDOWN messages
before any other application and do somthing (like Beep).
Please help me.
|
|
|
|
|
You have to install global hook on keyboard .... To learn more about hooks - see SetWindowsHookEx function on MSDN Library.
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor@soukhov.com | ICQ:57404554 | http://soukhov.com
|
|
|
|
|
Hi,
I'm thinking of writing a game (war simulation). In that game, i'll have a number of objects which will have "records" with initial information. I think i would let people modify the database so they can enter their own information. For instance 1 object from the object model could be a brigade.
If you start, you could have a number of records with historical brigades which people can then alter if they feel the info is incorrect.
I was thinking of storing them in textformat. Storing data this way is not optimized and i'll have to write my own functions to search on the "database" (=object model data saved to disk) for information. If the number of records is big, loading them into memory for speedy search operations is not doable.
In that case, a database system might be more interesting. I've thought of Access but that's of course not free. I had a look at Interbase, but that would be pure overkill since it has a database server/ client and so on. I would need something like Access but free. Having SQL support would be great but not a requirement.
Now i'm not even sure what i should do. I see four options:
1. Go with text files and write own search functions
2. Write the data binary and make an editor to manipulate object data.
3. Go with access and pretend to know nothing
4. Use an easy-to-use free database.
Any suggestions on what i would use best? In the case of database, any free database systems?
Also, does anybody know a good webpage for an analysis method? I learned several at the uni but they don't quit seem easy and practical enough.
Are there any freeware analysis tools around?
Thanks,
Bene
|
|
|
|
|
Another freebee database is mysql. It's still a client/server thingy but it's a bit lighter weight than Interbase.
Quite a lot depends on the ammount of data you are expecting to juggle. If there's only a moderate ammount it's generally more efficient to load the whole thing into memory at the beginning than use database access (whatever external format you chose).
If it's complex heirarchical data of limited size you might consider XML as a backing-store format. If you can get access to an XML editor it's a fairly nice way of organising data.
|
|
|
|
|
Thanks for the answer, i'll have a look at mysql then.
i was hoping for a non client server based database but of you say it's "lighter", then it might be okay anyway.
If i don't go with a database, i'll probably take a XML textbased database approach.
Anyway, thanks for the info
|
|
|
|
|
i took a quick look at mysql and it looks good but again client server (as you said) and that's not what i need. something in the lines of Access would have been great. Alas, i'll have to revert to XML text databases then. I have seen that apache and ibm both have a free parser. I took a quick look at the code from apache and man, pfew, this is nice code when it comes to syntax and reabability. I was impressed. A class factory (alla com), const correctness, good way of documenting (maybe a bit to short) and so on. A must-see if you are interested in improving your code readability.
|
|
|
|
|
Well, Access is not free, but the Jet database engine is (this is one of the two db engines that Access uses - the other one, SQL Server, is actually also free, in the form of MSDE. Look this up at MSDN). So if you don't need the Access UI to do the db manipulations, but instead write your own interface, you'll do just fine with Jet.
Of course, this is only works on Win platform.
Steen.
|
|
|
|
|
How can I conver the following code to MFC. I keep getting errors dealing with hDC.
Thanks.
VOID UpdateGrid( HWND hDlg, FLOAT x, FLOAT y )
{
static LONG s_lPixel[5] = { 0,0,0,0,0 };
static LONG s_lX = 0;
static LONG s_lY = 0;
HWND hWndGrid = GetDlgItem( hDlg, IDC_RENDER_WINDOW );
HDC hDC = GetDC( hWndGrid );
RECT rc;
// Replace pixels from that were overdrawn last time
SetPixel( hDC, s_lX-1, s_lY+0, s_lPixel[0] );
SetPixel( hDC, s_lX+0, s_lY-1, s_lPixel[1] );
SetPixel( hDC, s_lX+0, s_lY+0, s_lPixel[2] );
SetPixel( hDC, s_lX+0, s_lY+1, s_lPixel[3] );
SetPixel( hDC, s_lX+1, s_lY+0, s_lPixel[4] );
// Convert the world space x,y coordinates to pixel coordinates
GetClientRect( hWndGrid, &rc );
s_lX = (LONG)( ( x/ORBIT_MAX_RADIUS + 1 ) * ( rc.left + rc.right ) / 2 );
s_lY = (LONG)( (-y/ORBIT_MAX_RADIUS + 1 ) * ( rc.top + rc.bottom ) / 2 );
// Save the pixels before drawing the cross hair
s_lPixel[0] = GetPixel( hDC, s_lX-1, s_lY+0 );
s_lPixel[1] = GetPixel( hDC, s_lX+0, s_lY-1 );
s_lPixel[2] = GetPixel( hDC, s_lX+0, s_lY+0 );
s_lPixel[3] = GetPixel( hDC, s_lX+0, s_lY+1 );
s_lPixel[4] = GetPixel( hDC, s_lX+1, s_lY+0 );
// Draw a crosshair object in red pixels
SetPixel( hDC, s_lX-1, s_lY+0, 0x000000ff );
SetPixel( hDC, s_lX+0, s_lY-1, 0x000000ff );
SetPixel( hDC, s_lX+0, s_lY+0, 0x000000ff );
SetPixel( hDC, s_lX+0, s_lY+1, 0x000000ff );
SetPixel( hDC, s_lX+1, s_lY+0, 0x000000ff );
ReleaseDC( hWndGrid, hDC );
}
-Matt Newman
|
|
|
|
|
A few issues:
1/ GetPixel, SetPixel are VERY slow methods - use them at your own risk
2/ CDC is a thin wrapper on an HDC, it is likely to work exactly the same except that it will handle the HDC being released when going out of scope.
The correct way would be within the grid in OnEraseBackground or OnPaint to use the CDC there. If you want to do it outside these methods, then you can construct a CDC from a HDC. The method you want is CDC::Attach, as in
CDC dc;
dc.Attach(hDC);
Christian
Secrets of a happy marriage #27:
Never go to bed if you are mad at each other. It's more fun to stay up and fight.
|
|
|
|
|
Thanks
-Matt Newman
|
|
|
|
|
Add :: before each function call and use it as it is.
eg ::SetPixel() instead of SetPixel()
|
|
|
|
|
Hi,
I'm dealing with dialog based window with a lot's of graphics.
I'm not using Invalidate() anywhere - instead I do
-----------------
dc.BitBlt(0, 0, m_nWallpaperWidth, m_nWallpaperHeight , &m_dcMemory, 0, 0, SRCCOPY);
------------------------
in OnPaint function - this copies always updated offscreen dc to real ( viewable ) one.
The problem is : when I run few copies of this application and put windows
one on other and start moving them , sometimes there're GREY RECTANGLES and LINES
left on bottom windows.
This probably happens because overlapped window just
doesn't have enough time to update itself.
So , I was told by somebody that there exists window style/mode that Windows OS itself
restores overlapped areas of windows from Video Card Memory without making applications
themself to do it in their OnPaint.
It actually means , that these windows just won't get WM_PAINT message - "windows OS" will
restore them.
Maybe I just need to override OnEraseBkgnd , but i tried it ( drawing with NULL brush and
returning TRUE ) and it doesn't help.
I hope it was clear enough and somebody who understand me will say
1) if there is really such a style/mode
2) how exactly it's called
3) how i apply it
Thanks !
Leon
|
|
|
|
|
You can register the window class with the CS_SAVEBITS style flag. See the docs for the WNDCLASS structure. This might be what you are looking for, but it isn't recommended for large windows.
|
|
|
|
|
Nice, I'll check this in MSDN.
You are the one , that always helps me - Thank You Tim !
BTW , what is "large" window - how much is it in MB ?
|
|
|
|
|
The CS_SAVEBITS style that I mentioned in that last message is for saving the bitmap of the screen the window will obscure - not the window itself.
Still, it might be what you had heard mentioned.
Have you tried responding to WM_ERASEBKND with a BitBlt as well?
|
|
|
|
|
Cool idea, checking it just right now ...
|
|
|
|
|
Ok , placing the same code as in OnPaint to OnEraseBkgnd doesn't help.
I've read MSDN about cs_savebits :
----------------------------
CS_SAVEBITS :
Menus, dialog boxes, and combo list boxes have the CS_SAVEBITS style. When you use this style for a window, Windows saves a bitmap copy of the screen image that the window obscures. First, Windows asks the ...
----------------------------
Seems like it's exactly what I need , BUT it's written that dialog based applications ALREADY HAVE IT ( see above ) - correct me if i'm wrong.\
If not , how I apply it - dialog doesn't have PreCreateWindow like Window applictaion.
|
|
|
|
|
You would need to register a new window class to use CS_SAVEBITS, but again I don't think its what you want - it will only cause your window to save the bitmap of what it is on top of, which won't help you - only the window you're covering.
Blatant plug: I posted an article here that plays with blits and tries to outline the paint messages that need to be dealt with. Although it's a bit non-standard, it might give you some ideas.
|
|
|
|
|
Some thoughts:
- draw only in OnEraseBkgnd
- what are you drawing on, in the dialog? are there controls on it?
- why don't you use a child window to draw?
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
How can I make a edit box scrolling down and stay scrolled down as data is entered into it. Any Help will be greatly appreciated.
-Aaron
|
|
|
|
|