|
If you're not using ON_COMMAND_UI handlers (i.e: if you have a standalone menu or are building a dialog based app), you can use CMenu::ModifyMenu() to check/disable/gray a menu item.
/ravi
"There is always one more bug..."
ravib@ravib.com
http://www.ravib.com
|
|
|
|
|
My function (in my DLL-VC) have to return to the Delphi client program a array of 801 characters . BYTE arr[801]
that 801 can include everyone from the characters that exist and even NULL s
since Delphi have not type BYTE* or CString
The problem:
If my function gets char* and try to write into,
it gives error "access invalidation..." at Delphi
If the function returns char* ,
the Delphi program don't know where the string terminate because that string can contain some NULLs that confuses the program.
How it possible that the function vc++ could to give array of characters at constant length (as 801 bytes) for Delphi program ???
|
|
|
|
|
in my Document class the function serialize... I wan,t to save my data as a monochrome bitmap so I do
void CWoopDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
CBitmap BitMapTemp;
CDC CBitmapDC;
CBitmap* OldBitMap;
CBitmapDC.CreateCompatibleDC(NULL);
void * bitmapbitstemp = malloc( Size_X*Size_Y / sizeof(BYTE));
BitMapTemp.CreateBitmap(Size_X,Size_Y,1,1,bitmapbitstemp);
OldBitMap = CBitmapDC.SelectObject(&BitMapTemp);
BITMAPFILEHEADER BmpFileH;
BITMAPINFOHEADER bmpInfoH;
BITMAP bm;
BitMapTemp.GetBitmap(&bm);
BmpFileH.biBitCount = bm.bmBitsPixel;
BmpFileH.biCompression = BI_RGB;
BmpFileH.biHeight = bm.bmHeight;
BmpFileH.biPlanes = bm.bmPlanes;
BmpFileH.biWidth = bm.bmWidth;
BmpFileH.biSizeImage = BI_RGB;
BmpFileH.biClrUsed = 0;
BmpFileH.biClrImportant = 2;
BmpFileH.biXPelsPerMeter = 0;
BmpFileH.biYPelsPerMeter = 0;
BmpFileH.biSize = sizeof(BmpFileH);
bmpInfoH.bfOffBits = sizeof(bmpInfoH)+sizeof(BmpFileH);
bmpInfoH.bfSize = bm.bmWidthBytes;
bmpInfoH.bfType = ('M' << 8 | 'B');
bmpInfoH.bfReserved1 = 0;
bmpInfoH.bfReserved2 = 0;
ar.Write(&BmpFileH,sizeof(BmpFileH));
ar.Write(&bmpInfoH,sizeof(bmpInfoH));
ar.Write(bm.bmBits,bm.bmWidthBytes);
CBitmapDC.SelectObject(OldBitMap);
delete bitmapbitstemp;
}
else
{
}
}
BitMapTemp.Serialize(ar); //do not work...
any help will be fine...
Remi Morin
Rmorin@Operamail.com
Remi.Morin@Lyrtech.com
|
|
|
|
|
Are you sure you're drawing in the correct map? Using CBitMapDC->LineTo etc?
It sounds as if there is nothing in BitMapTemp.
Hope this helps,
Bill
|
|
|
|
|
Hi, all, I have problem doing a replacement of text in my text editor using
CRichEditView class. I want to replace some text that the user types but
have no idea what functions I can use. I am aware of the
GetRichEditCtrl( ).Paste, which can paste a copied text at the position of
the caret, but how do I insert a not clipboard stuff, such as a CString
object.
Peace, no war
|
|
|
|
|
Hi, all, I'm programming a text editor with spell check using MFC's
CRichEditView class. Anybody knows how to move the caret?
My usage is that when the user types a word that is found spelled wrong, the
editor has to move its caret to the word's beginning position and replace
the word. I'm new to Windows programming. I have no idea how to move the
caret and replace the word. I tried typing SetCaretPos( ) and ShowCaret( )
in the CMainFrame derived from CFrameWnd, but it didn't actually move the
caret. The caret seemed to change its postion to the one I set in
SetCaretPos( ), but when I used GetRichEditCtrl( ).Paste to paste a text for
a test, the text was pasted at the position as if I didn't do the
SetCaretPos( ).
Peace, no war
|
|
|
|
|
try :
GetRichEditCtrl().SetSel(caretPos, caretPos);
|
|
|
|
|
Thanks, squizz, this is great.
|
|
|
|
|
hi, all
i derived a class from CObject, and also let it support "runtime type information"(RTTI), so i did these:
// Derived.h
class CDerived : public CObject{
DECLARE_DYNAMIC(CDerived)
public:
CDerived(){};
~CDerived(){};
}
// Derived.cpp
IMPLEMENT_DYNAMIC(CObject, CDerived)
but there are a warning and a error:
Derived.cpp(19) : warning C4273: 'public: static struct CRuntimeClass const CObject::classCObject' : inconsistent dll linkage. dllexport assumed.
Derived.cpp(19) : error C2491: 'CObject::classCObject' : definition of dllimport static data member not allowed
can you tell me why?
thank you!
|
|
|
|
|
Hello Grant,
I think you make a little mistake:
you typed:
IMPLEMENT_DYNAMIC(CObject, CDerived)
instead:
IMPLEMENT_DYNAMIC(CDerived, CObject)
Hope that help!
|
|
|
|
|
Thank you very much, thank you all.
such a silly question, ha...
|
|
|
|
|
RTTI information is a feature of the C++ language that requires no M$ macros or classes. Just use dynamic_cast, and if the return is NULL, the object was not of the type you were casting to.
The M$ version, like the M$ container classes, were a stopgap, not a replacement.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Has anybody used MySQL via MFC? All I need to do first off is get a noddy database working programmaticly using MySQL in MFC. eg
Name Table:-
(Unique ID,Surname,Forename,DOB,UniqueKey)
Address Table:-
(Unique ID,LineOne,District,Town,County,PostCode)
Contact Table:-
(UniqueID,Number,Type)
Can anybody do this in their coffee break? Im stuck where to start is the problem. Im sure its a doddle though.
"Life begins at 140"
|
|
|
|
|
Really what is the need to repost? I answered your first question. Perhaps you should follow my advice. Read MSDN a little too. People here are happy to help, but not to do your work for you.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
The reason I reposted is that you did not answer my question. I was happy to receive a response: however I do not want to use MyODBC! That is the whole point. It is too slow. I want to use MySQL++ preferably or MySQL c api. Any further constructive responses are welcome.
"Life begins at 140"
|
|
|
|
|
You said you want to use MySQL via MFC, and the MFC database classes are based on ODBC (requiring the use of MyODBC). If you want to use MySQL++ or MySQL C API, you won't be using it via MFC.
|
|
|
|
|
What you said is correct except for one thing. Its not necessary to use CRecordset. If you avoid CRecordset then you dont require ODBC drivers. I have now managed to create a project using MySQL++ api directly. It is many times faster than interfacing to the MySQL api via ODBC eg opening a table via ODBC driver was s - l - o - w ~ 2 seconds a table as opposed to 0.05 seconds using the MySQL++ api directly. That was the question I was asking and which nobody attempted to answer.
"Life begins at 140"
|
|
|
|
|
Bill Gates Antimatter Particle wrote:
Can anybody do this in their coffee break?
Ouch!!!!
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
There's following problem :
When I try to add schema to XMLSchemaCache
the program fails.
MSXML2::IXMLDOMSchemaCollectionPtr pSchemaColl(__uuidof(MSXML2::XMLSchemaCache));
//schema ptr
if(pSchemaColl!=0)
{
hr=pSchemaColl->add(_bstr_t(L"x-schema:books"),
_variant_t(L"c:\\temp\\bookschema.xml"));
//here the program fails.
...
}
I tried to load some other XML schema (the one below) and it succeeds.
//=============================================
<Schema xmlns="urn:schemas-microsoft-com:xml-data">
<ElementType name="TITLE" />
<ElementType name="AUTHOR" />
<ElementType name="PUBLISHER" />
<ElementType name="DATE" />
<ElementType name="BOOK" model="closed">
<element type="TITLE" />
<element type="AUTHOR" />
<element type="PUBLISHER" />
</ElementType>
<ElementType name="COLLECTION" model="closed">
<element type="BOOK" />
</ElementType>
</Schema>
//=============================================
[on the other hand XML Spy says that this document is not valid..
but, it doesn't matter - I don't need it]
The problem is that I cannot load (add_method) schema generated/edited
with XMLSpy using MSXML Parser.
For example: XMLSPY claims that the below schema is valid
(both syntax and sematics) , but the VC++ code fails when loading
it (add method).
//=============================================
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xsd:element name="all_devices">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="device" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="device">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="part_name"/>
</xsd:sequence>
<xsd:attribute name="code" type="xsd:string" use="required"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="part_name" type="xsd:string"/>
</xsd:schema>
//=============================================
Is there any namespace conflict or something ?
What do I do wrong. Thanx for any suggestions.
Michal Januszczyk
|
|
|
|
|
I have created a dialog with a grid drawn directly on to it. I use the cursor keys to traverse that grid. However I also have two buttons on the dialog, the cursor keys affect the buttons, by chaning the currently selected button. I have turned tabbing off on the buttons but still the focus changes when the cursor buttons are pressed. Is there a way of stopping this??
Please help me, cos it is driving me nuts!!!!!
Andy
|
|
|
|
|
Try setting focus back to the last selected grid element in the button handlers.
/ravi
"There is always one more bug..."
ravib@ravib.com
http://www.ravib.com
|
|
|
|
|
I am not actually using any control for the grid, it is directly painted onto the dialog using the PDC*. I somehow need to stop a cursor message getting passed to the buttons, any ideas how?
Andy
|
|
|
|
|
I don't know how to easily do that. You may want to use a different approach. Drawing directly on the dialog's background for purposes other than adornment is probably not a good thing to do.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
When I try to launch an external app with args, it doesn't work. It try to launch an app with name equal to my args. After several tests for string AppName and CommandLine of CreateProcess, when I launch sucessfully app, the external app doesn't receive my args.
My code below:
HANDLE LanceProcess(CString nom_fic_exec,CString paramstring)
{
char param[500];
STARTUPINFO startup_info; // STARTUPINFO
/* Set up the STARTUPINFO structure for the CreateProcess() call */
memset(&startup_info, 0, sizeof(startup_info));
startup_info.cb = sizeof(startup_info);
PROCESS_INFORMATION proc_info; // PROCESS_INFORMATION
strcpy(param,(LPCTSTR)nom_fic_exec);
strcat(param," ");
strcat(param,(LPCTSTR)paramstring);
if (!CreateProcess(NULL,(LPSTR)param,NULL,NULL,TRUE,NORMAL_PRIORITY_CLASS,NULL,NULL,&startup_info,&proc_info)) {
DWORD erreur=GetLastError();
CString chaine;
chaine.Format("Problème lors du lancement du process %s %s",nom_fic_exec,paramstring);
AfxMessageBox(chaine);
}
return(proc_info.hProcess);
}
|
|
|
|
|
Try this. You ought to specify the executable name in first arg of createprocess, and use the second solely for your arguments.
Also, Virtually everything in CreateProcess is nullable. Including the last arg, for process information. But i included that since it looks like you wanted a process handle.
Jon
HANDLE LanceProcess(CString nom_fic_exec,CString paramstring)
{
BOOL bStatus; PROCESS_INFORMATION PI;
CString strProcess = nom_fic_exec;
CString strCommandLine=paramstring;
bStatus=CreateProcess( (LPCSTR) strProcess,
(LPTSTR) strCommandLine.GetBuffer(MAX_PATH),
NULL,
NULL,
TRUE,
NORMAL_PRIORITY_CLASS,
NULL,
NULL,
NULL,
&PI );
if (!bStatus)
AfxMessageBox("your error message);
return PI.hProcess;
}
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|