|
I create a MFC project with Dialog based and I put a CRichEditCtrl into the dialog.
when I run the project,it has nothing.
Should I do before running the project?
Do I initialize the CRichEditCtrl?
Thank you!
|
|
|
|
|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_CRichEditCtrl.asp[^]
The short version:
If you are using a rich edit control in a dialog box (regardless whether your application is SDI, MDI, or dialog-based), you must call AfxInitRichEdit once before the dialog box is displayed. A typical place to call this function is in your program's InitInstance member function. You do not need to call it for each time you display the dialog box, only the first time. You do not have to call AfxInitRichEdit if you are working with CRichEditView.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
According to your hint,the question was solved!
The window would be showed after running program.
Thank you very much!
|
|
|
|
|
Guys,
Sorry if this is a FAQ
I am looing for exampe source code of a Windows service that can listen on a given port and efficiently communicate with (possibly) multiple client.
The APP should be developped under visual C++ version 6.0 and upwards, and would preferbly have a management aplette associated with it. Desktop interaction is a definate +
Youd help is much appreiated. My e-mail is worldentropy@yahoo.co.uk
|
|
|
|
|
prof.hell wrote:
Youd help is much appreiated. My e-mail is worldentropy@yahoo.co.uk
As Mr. Archer Says
"I don't think you're going to get much help with an "email me for better understanding" post. This forum is not meant for people to do other's work. Rather we help people who are facing specific problems that they've defined during their development.
Do you have a specific question or are you looking for someone to basically write your application for you? "
Hope so you got my point
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
I'm trying to create a toolbar with 256 color icons. I tried creating an ImageList and loading the images with LoadImage, but everything I tried either show the icon's transparant parts as black or white, or it changes the colors to what I'm guessing is Window's defualt 256 color palette. So, how do you go about creating a toolbar that show icons with transparency and with it's own palette?
- thanks.
|
|
|
|
|
I am trying to use ADO in C++ and am having problems. From several sources, including the help files, I have gotten this simple means of instantiating of a Connection object:
#import "C:\Program Files\Common Files\System\ado\msado15.dll" \
rename ( "EOF", "adoEOF" )
#include "DEBUG\msado15.tlh"
#include "DEBUG\msado15.tli"
/////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////
BOOL ADODB_OpenDatabase(HWND hWnd)
{
ADODB::_ConnectionPtr conn;
HRESULT hr;
BOOL bRet = FALSE;
int err;
hr = CoInitialize(NULL);
if(FAILED(hr))
{ MessageBox(hWnd, "CoInitialize() failed", "OpenDatabase", MB_OK|MB_TOPMOST);
break;
}
// Create connection. (here is where I get the error 340)........
hr = conn.CreateInstance(__uuidof(ADODB::_Connection));
if(FAILED(hr))
{ err = HRESULT_CODE(hr);
ErrorMessage("Failed to create connection", "OpenDatabase", err);
goto FINISHED;
}
// Success.......................................................
bRet = TRUE;
// Cleanup.......................................................
FINISHED:
return bRet;
}
void ErrorMessage(TCHAR *szMsg, TCHAR *szCaption, int err)
{
LPVOID lpMsgBuf = 0;
TCHAR szErr[2001];
int nError;
if(err < 1)
nError = GetLastError();
else
nError = err;
if(!nError)
wsprintf(szErr, "%s. Error: %d", szMsg, nError);
else
{
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
nError,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL);
wsprintf(szErr, "%s. Error: %d. \r%s", szMsg, nError, (LPCTSTR)lpMsgBuf);
}
MessageBox(NULL, szErr, szCaption, MB_OK|MB_TOPMOST);
}
When I try to instantiate the connection object "conn" it get a bad HRESULT that is converted to Win32 error 340 which is not defined in the help files.
Any help would be greatly appreciated.
Rick C.
Thanks
Rick C.
|
|
|
|
|
Sorry, I put this together too quickly. Here is a better (valid) ADODB_OpenDatabase function. (same problem)
BOOL ADODB_OpenDatabase(HWND hWnd)
{
ADODB::_ConnectionPtr conn;
HRESULT hr;
BOOL bRet = FALSE;
int err;
hr = CoInitialize(NULL);
if(FAILED(hr))
{ MessageBox(hWnd, "CoInitialize() failed", "OpenDatabase", MB_OK|MB_TOPMOST);
goto FINISHED;
}
// Create connection.............................................
hr = conn.CreateInstance(__uuidof(ADODB::_Connection));
if(FAILED(hr))
{ err = HRESULT_CODE(hr);
ErrorMessage("Failed to create connection", "OpenDatabase", err);
goto FINISHED;
}
// Success.......................................................
bRet = TRUE;
// Cleanup.......................................................
FINISHED:
CoUninitialize();
return bRet;
}
Thanks
Rick C.
|
|
|
|
|
I figured it out. You must CreateInstance on 'Connection' not '_Connection' even though it does not show up in intellisense. I will post the new code to help anyone else who has this problem.
/////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////
BOOL ADODB_OpenDatabase(HWND hWnd)
{
ADODB::_ConnectionPtr conn;
HRESULT hr;
BOOL bRet = FALSE;
int err;
hr = CoInitialize(NULL);
if(FAILED(hr))
{ MessageBox(hWnd, "CoInitialize() failed", "OpenDatabase", MB_OK|MB_TOPMOST);
goto FINISHED;
}
// Create connection.............................................
hr = conn.CreateInstance(__uuidof(ADODB::Connection));
if(FAILED(hr))
{ err = HRESULT_CODE(hr);
ErrorMessage("Failed to create connection", "OpenDatabase", err);
goto FINISHED;
}
// Success.......................................................
bRet = TRUE;
// Cleanup.......................................................
FINISHED:
conn = NULL;
CoUninitialize();
return bRet;
}
One more reason I don't like oop or com.
Thanks
Rick C.
|
|
|
|
|
Hello,
I need to start working in Javascript for the first time.... it seems pretty straight forward. Right now, I have VC++ and Dreamweaver, should I get the J++ or is there another Java Script development environment that you suggest?
thanks!
JennyP
|
|
|
|
|
I have used Spy++ to obtain the handle of a Window Panel and TreeView. I now want to use this handle to grab the tree. I don't understand how to do this ?? Any suggestions.
Once I grab the tree I want to be able to store this tree in a file.
Could someone please give me some direction here
Abhishek
|
|
|
|
|
Abhishek Karnik wrote:
now want to use this handle to grab the tree
Look at CTreeCtrl::Attach(...); and CTreeCtrl::Detach(...);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
if you please can u sent me some specific sites and examples not the MSDN or if so specifie to me wut should i write or where should i search .Because i am learning MFC newly and i have 1 week to hand in my project .
I need to know how can i read from a file or to a file in MFC classes and if u dont mind i would like to have an updating file example as well .
thank you in advance
|
|
|
|
|
CFile
Most of the member functions have examples, Open most likely has the most thorough example.
See CFile::modeNoTruncate flag for appending data to files.
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
The best way is to use standard C++ most of the time. If you google ifsteam or ofstream, you're bound to find some references.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I'm having trouble figuring out how to pass a
pointer to a double array (1 dimensional)
to a C function.
Declaring array as: double xx[100];
Declaring func. int process( double *input[] )
Calling func. as one of the following:
process ( xx );
process ( &xx[0] );
I get various "can't convert, can't recast"
error messages from the compiler.
I have also tried declaring a double pointer and
pointing address of index zero of the array to the
double pointer - no luck either.
Using Visual Studio/Visual C 6.0
Many thanks,
Robert
|
|
|
|
|
int process(double *input)
double xx[100];
xx[0] = 1.1;
xx[1] = 2.2;
xx[2] = 3.3;
xx[3] = 4.4;
...
process(xx);
|
|
|
|
|
|
Declaring array as: double xx[100];
Declaring func. int process( double *input[] )
The second one is a double pointer (pointer to an array). So, pass your array like:
process(&xx);
Best regards
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
You can write either of these in the function:
int process ( double* input );
int process ( double input[] ); The two are equivalent, and the equivalence is an artifact of C's predecessor languages. Note that you also need a way to tell process() the size of the array, because the input parameter is just a pointer. The usual way is to add a second parameter of type size_t where you pass the number of elements in the array.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
Gentlemen,
Thank-you for your assistance.
Have it working now.
All the best,
Robert
|
|
|
|
|
When I send a message to main thread I also have to send a string and an int.
I have to use LPARAM and WPARAM?
Here my code:
...
#define MY_WM_MESSAGE1 (WM_APP + 1)
...
ON_MESSAGE(MY_WM_MESSAGE1, OnMyMessage1)
...
LRESULT CProvaDlg::OnMyMessage1(WPARAM wParam, LPARAM lParam){
/***
// here I want to use a string and an int sent by message
*/
return 0; // I handled this message
}
Tnx
(sorry for my english)
|
|
|
|
|
When you send the message, cast the values to WPARAM and LPARAM and then cast them back in the message handler:
// sending
TCHAR* pszValue = _T("abc");
int iValue = 42;
SendMessage(hwnd, MY_WM_MESSAGE1, (WPARAM)pszValue, (LPARAM)iValue);
// receiving
LONG CYourClass::OnMessage1(WPARAM wp, LPARAM lp)
{
TCHAR* psz = (TCHAR*)wp;
int i = (int) lp;
...
|
|
|
|
|
CString* pString = new CString(_T("Text"));
int nNumber = 100;
PostMessage(hMyWnd, MY_WM_MESSAGE1, reinterpret_cast<WPARAM>(pString), reinterpret_cast<LPARAM>(nNumber));
The string must be allocated on the heap, otherwise it will bomb on you when it goes out of scope.
You'll need to free the memory for it when the OnMyMessage1 is received.
in OnMyMessage1...
CString* pString = reinterpret_cast<CString*>(wParam);
int nNumber = reinterpret_cast<int>(lParam);
...
delete pString;
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
Yes, as other have just suggested you may cast your int and string to wparam and lparam repectively.
But what are you going to do if you will need to pass more data than do not fit in two variables later? I'd suggest to declare a struct, that would contain any information you need to pass with a message. This has one long tern advantage - if the code to be tweaked sometime later, tweaking will not affect function signatures and the app's architecture.
<br />
struct MYMESSAGEDATA<br />
{<br />
int nInteger;<br />
char* nString;<br />
};<br />
<br />
...<br />
...<br />
MYMESSAGEDATA* pData = new MYMESSAGEDATA;<br />
pData->nInteger = 1;<br />
pData->nString = "string";<br />
...<br />
...<br />
<br />
::SendMessage(hwnd, msg, NULL, (WPARAM)pData); <br />
<br />
...<br />
LRESULT CProvaDlg::OnMyMessage1(WPARAM wParam, LPARAM lParam)<br />
{ <br />
MYMESSAGEDATA* pIncomingData = (MYMESSAGEDATA*)lParam;<br />
<br />
<br />
...<br />
...<br />
<br />
delete pIncomingData;<br />
<br />
return 0;<br />
}<br />
As you can see in above example, you have a spare wParam which could be used to pass, for example, ID of the sender of the message, consider it as another advantage of this approach.
|
|
|
|