|
Try using the MSDN[^] web site first.
Software Zen: delete this;
|
|
|
|
|
I created a Global hook by creating a DLL that listens for the WH_SHELL message . I get notifications for all top level window creations .
Now I have a method in my DLL that looks like
MYShellProc(code , wParam ,Lparam)
{
...
return CallNextHook(....)
}
void DoSomething()
{
CEvent myEvent l
..
..
event->Lock(15000);
}
It is during this wait that I DO NOT GET any SHELL notifications during the wait . Is it due to the fact that my main thread is blocked in the wait ? Are there any workarounds ?
-- modified at 4:08 Saturday 12th November, 2005
|
|
|
|
|
inGrid is a MSHFlexGrid object.
...
...
inGrid.Clear();
inGrid.SetCols( 0, 3); //This line sometimes cause Access Violation problem.
...
...
Do anyone ever had this problem or know how to solve it?
Here's the call stack when the problem happen
==================================
MSHFLXGD! 01a908d0()
MSHFLXGD! 01a79abb()
MSHFLXGD! 01a75b2f()
MSHFLXGD! 01a8fdc6()
MSHFLXGD! 01a72d31()
OLEAUT32! 779d7d5d()
OLEAUT32! 77a2310e()
MSHFLXGD! 01a95945()
MSHFLXGD! 01a7dd7c()
COleDispatchDriver::InvokeHelperV(long 5, unsigned short 4, unsigned short 0, void * 0x00000000, const unsigned char * 0x006a01dc parms, char * 0x0012f7e4) line 345 + 54 bytes
COleControlSite::InvokeHelperV(long 5, unsigned short 4, unsigned short 0, void * 0x00000000, const unsigned char * 0x006a01dc parms, char * 0x0012f7dc) line 976
CWnd::InvokeHelper(CWnd * const 0x016f2550 {CSelectionGrid hWnd=0x00320ce8}, long 5, unsigned short 4, unsigned short 0, void * 0x00000000) line 354
MSHFlexGrid::SetCols(long 0, long 3) line 56 + 30 bytes
-- modified at 0:46 Saturday 12th November, 2005
|
|
|
|
|
Hello All
I want to store a BINARY file content (size of the BINARY file can be from 4 to 30 MB) to SAFEARRAY. I am reading the file content in BYTE*. For storing the data to SAFEARRAY, I found the API SafeArrayPutElement. But using this I have to copy BYTE by BYTE. Is there any way to copy full data of type BYTE* or char* or CString to SAFEARRAY?
Currently I am using
for(nBufIndex=0; nBufIndex < nFileSize; nBufIndex++)<br />
{<br />
hr = SafeArrayPutElement(l_pSafeArray, &l_lSAIndex, &pBuffer[nBufIndex]);<br />
l_lSAindex++;<br />
}
Thanks for your time
Ravi
|
|
|
|
|
SAFEARRAY *psa;
psa = SafeArrayCreateVector( VT_UI1, 0, LengthInBytes );
unsigned char *pData = NULL;
SafeArrayAccessData( psa, (void**)&pData );
memcpy( pData, pMemData, LengthInBytes );
SafeArrayUnaccessData(psa);
SkyWalker
|
|
|
|
|
im creating a helper class to hide and show the following controls:
ControlBar
ReBar
ToolBar
DialogBar
StatusBar.
my problem is i dont know how to hide/show those items using a class. If you know some articles or links or you know how to do it, please reply to my post.
Thanks! Your help is deeply appreciated.
|
|
|
|
|
I have used the Dialogbar it also had problem
to Show/Hide ,
ControlBar is the base class of Dialogbar
hence i used a pointer to the MainWnd and
then use to Show/Hide by setting the thirdparameter
as TRUE/FALSE.
this->ShowControlBar((CControlBar*)&m_dlgbar,TRUE,0);
//this is a ptr to MainWnd
U can try this type of trick for your class
Its a good effort will be help full to many developers
do post me the copy of the class when u have done it
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
Get handle of the item that you would like to show or hide. Then use the ShowWindow() function to proceed.
Rajesh R. Subramanian
Akruti Software,
Bombay, India.
|
|
|
|
|
Hello all, using the ADO _ConnectionPtr->Exexute() method, i can add new rows to my Access 2000 database, the problem is like this, assume theres a table called people, with fields per_id of type Autonumeric, and name of type Text(50), if i write my sql to add a new record like this:
INSERT INTO people VALUES(NULL, 'mike')
then i get a com exception saying that i cannot assign Null to a non Variant type variable. If i write it like:
INSERT INTO people VALUES(0, 'mike')
it works (once), but the database actually sets per_id to 0, instead of asigning an anuto-incremented value. So the question is:
what should i pass to an INSERT INTO statement when one of the fields is autoincrement?
Thanks!
|
|
|
|
|
Ah! never mind guys, i just figured out:
INSERT INTO people (name) VALUES('mike')
Thanks NE way
|
|
|
|
|
I have been developing GUI applications for years in VB, but I am pretty new when it comes to VC++, so any help would be appreciated.
How do I create a MDI application that starts maximized and DOES NOT create a child window? I want to be able to create the window based on toolbar and menu commands not when the app starts.
Thanks!
|
|
|
|
|
write this code in ur app's Initinsatance function to prevent ur app from creating a child window during startup
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
//DON'T display a new MDI child window during startup!!!
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
to start the window maximized
pMainframe->ShowWindow(m_nCmdShow); replace this by below line
pMainfram->ShowWindow(SW_SHOWMAXIMIZED);
Bye
Cool Ju
|
|
|
|
|
Thanks..That worked great!
|
|
|
|
|
In my SDI project in VC6.0, I want to derive a class from CArchive(), which will have two new methods:
WriteFormatString( ) and ReadFormatString( )
which basically follow the printf and scanf style.
so I have this included in MyDoc.h:
#include "MyArchive.h"
and in the same file, changed
virtual void Serialize(CArchive& ar);
to
virtual void Serialize(CMyArchive& ar);
In MyDoc.cpp,
I changed
void CMyDoc::Serialize(CArchive& ar)
to
void CMyDoc::Serialize(CMyArchive& ar)
But when I click on open or save menu items,
void CMyDoc::Serialize(CMyArchive& ar)
is not called.
What am I missing here?
Thank you very much for your help!
|
|
|
|
|
Hi,
When u change the serialize(CArchive& ar) to Serialize(CMyArchive& ar) it becomes a overloaded function and the compiler expects a definition for that function.
Write the function definition for Serialize(CMyArchive& ar) and override the Serialize(CArchive& ar) and call Serialize(CMyArchive& ar) from it.
Hope this solves ur problem.
Bye
Cool Ju
|
|
|
|
|
hi Cool Ju, Thank you for the direction, but I didn't quite follow.
How do I override Serialize(CArchive& ar)? I tried to replace
virtual void Serialize(CArchive& ar)
with
virtual void Serialize(CMyArchive& ar)
in myDoc.h, but it doesn't work.
Now what I do is in myDoc.h, add
virtual BOOL OnSaveDocument(LPCTSTR lpszPathName);
and in myDoc.cpp, implemented it as follows:
<br />
<br />
CFileException fe;<br />
CFile* pFile = NULL;<br />
pFile = GetFile(lpszPathName, CFile::modeCreate |<br />
CFile::modeReadWrite | CFile::shareExclusive, &fe);<br />
<br />
if (pFile == NULL)<br />
{<br />
ReportSaveLoadException(lpszPathName, &fe,<br />
TRUE, AFX_IDP_INVALID_FILENAME);<br />
return FALSE;<br />
}<br />
<br />
CMyArchivesaveArchive(pFile, CArchive::store | CArchive::bNoFlushOnDelete);<br />
saveArchive.m_pDocument = this;<br />
saveArchive.m_bForceFlat = FALSE;<br />
TRY<br />
{<br />
CWaitCursor wait;<br />
Serialize(saveArchive);
saveArchive.Close();<br />
ReleaseFile(pFile, FALSE);<br />
}<br />
CATCH_ALL(e)<br />
{<br />
ReleaseFile(pFile, TRUE);<br />
#if 0<br />
TRY<br />
{<br />
ReportSaveLoadException(lpszPathName, e,<br />
TRUE, AFX_IDP_FAILED_TO_SAVE_DOC);<br />
}<br />
END_TRY<br />
DELETE_EXCEPTION(e);<br />
#endif<br />
return FALSE;<br />
}<br />
END_CATCH_ALL<br />
<br />
SetModifiedFlag(FALSE);
<br />
return TRUE;
<br />
but I got a new problem here, I have to #if 0 some of the code out, cause the compiler complains that DELETE_EXCEPTION is not defined.
more hints please?
|
|
|
|
|
Hi lucy,
CDocument::OnSaveDocument(lpszPathName) internally calls serialize(CArchive savearchive)
Donot call serialize explicitly from CMyDoc::OnSaveDocument()
Instead try this
BOOL CMyDoc::OnSaveDocument(LPCTSTR lpszPathName)
{
BOOL bRetVal = CDocument::OnSaveDocument(lpszPathName);//this will internally call serialize()
}
Override serialize() by
void CMyDoc::Serialize(CArchive& ar)
{
CDocument::Serialize(ar); //first call parent's serialize
CMyArchivesaveArchive(pFile, CArchive::store | CArchive::bNoFlushOnDelete);
saveArchive.m_pDocument = this;
saveArchive.m_bForceFlat = FALSE;
CWaitCursor wait;
Serialize(saveArchive); // save me
saveArchive.Close();
ReleaseFile(pFile, FALSE);
}
void CMyDoc::Serialize(CMyArchive& saveArchive)
{
//write ur serialization code here
}
Bye
Cool Ju
Vote for Cool Ju
|
|
|
|
|
Thank you very much, Cool Ju, the coding is working now!
|
|
|
|
|
( maybe not the best wording for my question )
Let's say I have a vector :
std::vector< BaseObject* > myVector;
I can have an iterator like :
std::vector< BaseObject >::iterator it;
That will move on the vector.
now, if I have a class hierarchy with the BaseObject class as the class parent :
class Derive1 : public BaseObject {};
class Derive2 : public BaseObject {};
myVector.push_back( new Derive1 );
myVector.push_back( new Derive2 );
Is there a way with STL to iterate only on some type of object in the vector ?
For example, only iterator on the object of the type Derive1 instead of iterating over the whole list and manually each time check to see if it's of the right class ?
Or do I have to do a bigger wrapper over the vector ?
Thanks.
Max.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
|
The only way I can think of is using std::remove_if with a predicate function that does a dynamic cast. Not very pretty, IMO.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
IMHO the design is broken.
Relying on RTTI to query a heterogeneous collection either through a hand-rolled function or within the function object of the BOOST selective iterator mentioned is poor design.
This is C thinking within C++
I would suggest a rethink that does not sacrifice type safety.
Why do Derive1 & Derive2 have to be in the same collection?
They are not the same why try and treat them as if they are and then try and recast them?
|
|
|
|
|
#include <iostream>
#include <iomanip>
using namespace std;
bool Solve(int mat[][8], int x, int y);
void print(int mat[][8]);
void Initmat(int mat[][8]);
bool isvalid(int x, int y);
int counter=1;
int main() {
int mat[8][8];
Initmat(mat);
cout << "Generating solution...";
if (Solve(mat, 0, 0))
print(mat);
else cout << "No solution found" << endl;
return 0;
}
void Initmat(int mat[8][8]) {
for (int x = 0; x < 8; x++)
for (int y = 0; y < 8; y++)
mat[x][y] = 0;
}
void print(int mat[8][8]) {
cout << "Solution found!" << endl;
for (int x = 0;x < 8; x++) {
for (int y = 0; y < 8; y++)
cout << setw(4) << mat[x][y];
cout << endl;
}
}
bool Solve(int mat[8][8], int x, int y)
{
bool done=false;
if (counter == 65)
return true;
if (isvalid(x,y) && (mat[x][y] == 0))
{
mat[x][y] = counter; counter++;
if (!done)done=Solve(mat, x+2, y+1);
if (!done)done=Solve(mat, x+1, y+2);
if (!done)done=Solve(mat, x-1, y+2);
if (!done)done=Solve(mat, x-2, y+1);
if (!done)done=Solve(mat, x-2, y-1);
if (!done)done=Solve(mat, x-1, y-2);
if (!done)done=Solve(mat, x+1, y-2);
if (!done)done=Solve(mat, x+2, y-1);
if (!done){mat[x][y] = 0;counter--;}
}
return done;
}
bool isvalid(int x, int y) {
return ((x >= 0) && (x < 8) && (y >= 0) && (y < 8));
}
www.topsites.co.il
|
|
|
|
|
|
Howdy folks,
I'm having a little problem with FindFirstPrinterChangeNotification that has got me baffled. When I call this function on a laptop running XP Pro SP2 I get this error: This function is not supported on this system.
However this same .exe works fine on the other XP systems I've tested it on and calls the function with no problems.
If anyone has any insight into what could be causing this problem I would be very grateful for the help.
Thanks folks.
|
|
|
|
|