|
That's a neat tip!
|
|
|
|
|
Hi,
I have the problem that the below code
LOGFONT lf;
CFont font;
m_pWndOutput->ResetContent();
CFontDialog dlg;
if (dlg.DoModal()==IDOK)
{
dlg.GetCurrentFont(&lf);
if (font.CreateFontIndirect(&lf))
{
m_pWndOutput->SetFont(&font);
OutputAllItemsAgain();
}
}
which is a message handler of the Change Font button,
does not change the font itself in the ListBox (m_pWndOutput), it only changes the ListBox item height according to the font size specified in CFontDialog.
I tried this instead of a ListBox with a ListCtrl but experienced the same.
Could somebody please enlighten me?
Thanks
R.
|
|
|
|
|
Here is on solution.
// This should be in the class contructor.
-----
LOGFONT fontLog;
CDC dc;
memset(&fontLog, 0, sizeof(LOGFONT));
// set font size
fontLog.lfHeight = -MulDiv(11, GetDeviceCaps(dc, LOGPIXELSY), 72);
// set font type
strcpy(fontLog.lfFaceName, "Microsoft Sans Serif");
CFont *myFont;
myFont = new CFont();
myFont->CreateFontIndirect(&m_MsgLogFont);
-----
// This should be in the function you use to set the font.
-----
myFont->CreateFontIndirect(&m_MsgLogFont);
// Assuming this is a listview
GetEditCtrl().SetFont(myFont);
-----
Kuphryn
|
|
|
|
|
See the VC forum FAQ. The short answer is the CFont objec is a local variable and gets destroyed as soon as the function returns.
--Mike--
Just released - RightClick-Encrypt v1.3 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
I'm doing a program in serial communication and have some questions:
1.When does the EV_CTS events take place?
do I need to monitor it? Can you give me an example?
2.If I use the MSComm control in SDI document,how can I add it to the project, and monitor the comm event? Thanx!
|
|
|
|
|
Search in the MSDN for:
1. Serial Communications in Win32 Allen Denver Microsoft Windows Developer Support
2. "VCTERM: Uses the Microsoft Communications ActiveX Control"
Read on then post!
Papa
Murex Co.
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
hi,
i have a situation where i use a frameless doc to do background processing and later i have to save it.how can i do that? also how can i save a different doc created in its own frame and view,all registered with a template?
|
|
|
|
|
Hi.I'm writing a dialog based aplication with support for sockets.I created my own derived class from CAsyncSocket.Whenever a client sends the string "cat <file>" to the server (where file is an ascii text file), the server responds sending the contents of the specified file to the client.The problem is that, most of the times, the server just sends about half of the contents of the file to the server.Here is the code I created to do this :
//on the server side:
//loop to read the contents of the file, f is a CFile object
//nbytes an UINT variable
//PacketSend(..) is my function to send the buffer to the client
while ( (nbytes = f.Read(buf,512)) )
PacketSend(buf,nbytes);
f.Close();
//PacketSend(..) function
void CConversarDlg::PacketSend(void *buffer,const int &length)
{
int total = sizeof(int) + length;
int sent;
int bufpos = 0;
BYTE *buf = new BYTE[sizeof(int) + length];
memcpy(buf,&length,sizeof(int));
memcpy((void *) (buf+sizeof(int)),buffer,length);
do
{
sent = ClientSocket->Send(buf+bufpos,total);
if ( sent == SOCKET_ERROR ) break;
total -= sent;
bufpos += sent;
if ( total > 0 ) Sleep(20);
} while ( total > 0 );
delete [] buf;
}
//on the client side:
//I call the funtion ReceivePacket on the overridable CAsyncSocket::OnReceive(int)
//PacketReceive(..) function
void CXploreDlg::PacketReceive(unsigned char **buffer)
{
unsigned char *buf;
int length;
int recv;
int bufpos = 0;
//clientsocket is an object of the derived CAsyncSocket Class I created
recv = clientsocket.Receive(&length,sizeof(int));
if ( recv != sizeof(int) || recv == SOCKET_ERROR ) return;
buf = new unsigned char[length + 1]; //+1 for the NULL character
do
{
recv = clientsocket.Receive(buf+bufpos,length);
if ( recv == SOCKET_ERROR ) break;
length -= recv;
bufpos += recv;
if ( length > 0 ) Sleep(20);
} while ( length > 0 );
*(buf + bufpos) = NULL;
*buffer = buf;
}
On the begining of each packet, I use 4 bytes (int value) for the client aplication to know the length of the packet,the rest is the contents of the ascii file specified....
I'm new to sockets, so I would apreciate a lot a little help...
I'm also trying to write code for downloading and uploading files, but i got exactly the same problem I mencioned before....
Thanks.
Portugal.
Filipe David Manana
|
|
|
|
|
Which platform you are interested in ???? If you are ready to bound to Win 2000 and later OSs, then use the APIs like TransmitFile and TransmitBuffers
Imran Farooqui
|
|
|
|
|
Hello, the codegurus around the world.;)
When you try to transfer the file by CAsyncSocket class, you need some kind
of CFile class process to read or write some part of the files to the buffer.
And this buffer will be sent or received in the server or client respectively.
I didn't find this process, so I'm wondering how you create this buffer.
Or you insert whole file to the buffer only one time?
If so, this approach seems not to be good.
Or while the process inserts the data to the buffer, you may call PacketSend.
You may need some code to check if the buffer includes exact buffer
before PacketSend is called?
Please, don't send me your email about your questions directly.
Have a nice day!
Sonork - 100.10571:vcdeveloper
-Masaaki Onishi-
|
|
|
|
|
Sure this sounds silly considering the plethora of available RDBMS out there but does anything like the subject would suggest actually exist...???
Basically an advanced CFile w/ like Hybrid SQL support or something? That doesn't require any third party libs, drivers, dll's or anything...???
Just curious....
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
|
Hi, all
Some problems about ATL Com:
1.I have create two ATL Object: CStudent and CTeacher .
The simple source code listed as follow: (some code auto generated by ATL have been skiped)
class CStudent
{
private:
long m_age;
public:
CStudent():m_age(10)
{
}
//...other code auto generated by ATL
};
class CTeacher
{
private:
IStudent* m_aStudent;
public:
CTeacher()
{
//create an instance of the com
CoCreateInstance(CLSID_Student,NULL,CLSCTX_ALL,IID_IStudent, (void**)&m_aStudent);
}
//...other code auto generated by ATL
}
2.Then I add a "IStudent * OneStudent" property for ITeacher ,to access the m_aStudent.
The implemention of the property are listed as below:
STDMETHODIMP CTeacher::get_OneStudent(IStudent *pVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
// TODO: Add your implementation code here
*pVal = * m_aStudent;
return S_OK;
}
STDMETHODIMP CTeacher::put_OneStudent(IStudent *newVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
// TODO: Add your implementation code here
*m_aStudent = *newVal ;
return S_OK;
}
3.Now I type some VB code to test the com ,but some compiler errors occurrs.
VB Code:
Dim s As Student
Dim t As New Teacher
s = t.OneStudent
the last sentence "s = t.OneStudent" have compiler errors.
Errors:function or interface marked as restricted ,or the function use an Automation type not supported in Visual Basic
I guess the errors caused by the type dismatch between IStudnet and CStudent.But I did not know how to resolve it .
So who can tell me how to return the m_aStudent that can be supproted in vb??
thx.
Regards.
|
|
|
|
|
As I've already told you, you cannot return an instance of your class. You may be able to return a pointer to another COM object, but you cannot return a vanilla class instance. IDispatch interfaces ( i.e. Automation ) also have more restrictions than normal interfaces, if I remember correctly. If a teacher has lots of students, I think my original suggestion of returning their details as XML remains a good one.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
|
|
|
|
|
I am a newer to ATL.
I think I just return a pointer to another COM object .
STDMETHODIMP CTeacher::get_OneStudent(IStudent *pVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
// TODO: Add your implementation code here
*pVal = * m_aStudent;
return S_OK;
}
STDMETHODIMP CTeacher::put_OneStudent(IStudent *newVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
// TODO: Add your implementation code here
*m_aStudent = *newVal ;
return S_OK;
}
|
|
|
|
|
Is the IDL for get_OneStudent marked as [out,retval] for the IStudent parameter?
Is IStudent an IUnknown or IDispatch interface?
Michael
Time flies like an arrow. Fruit flies like a banana
|
|
|
|
|
You should returns a new object; something like:
STDMETHODIMP CTeacher::get_OneStudent(IStudent **pVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
**pVal = * m_aStudent;
(*pVal)->AddRef();
return S_OK;
}
Also note that others functions need to be modified. For example setting a new student would have to update the pointer (and properly adjusting reference count).
As mentionned in another answer, you cannot pass object around but only interface to objects...
Philippe Mori
|
|
|
|
|
How can i initialize my console app to use ADO. If the console app is MFC based then we use AfxOleInit() to initialize COM libraries and use #import statement in stdAfx.h.
But the application i want to make is pure console application without MFC support and without any StdAfx.h. So please tell me how I Initialize it that it can use ADO
Virtual Destructor
|
|
|
|
|
CoInitalize(NULL)
will allow you to call COM.
The #import stuff should then work.
Michael
Time flies like an arrow. Fruit flies like a banana
|
|
|
|
|
How can i know if the desktop windows Z order has been changed?
thanx
|
|
|
|
|
wazzup,
i am currently trying to get the user arguments as
MyApp.exe -argument
i have tried using the sample program by chris losinger. the argument which needed is captured on the command line is then passed through to the gui.
but instead nothing is captured. i am just not sure what is needed to be specified
Regards,
CaLvin Tan
|
|
|
|
|
Depends on whether it's a command-line or GUI app. For command-line, use the standard argc/argv arguments to main() .
For GUI, you can use the globals __argc and __argv that the CRT supplies, or call GetCommandLine() and parse it yourself.
--Mike--
Just released - RightClick-Encrypt v1.3 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Hi
I read OpenGL SuperBible and I making simple 3Dgame...
but I don't know How to darw shadow of sphere and line
shadow example of OpenGL SuperBible is shadow of object what
consist of 3 vertex
I want a example of sphere and line...
please help me~;)
dark
|
|
|
|
|
Hi, I'm wondering if anyone could help me enable multiple instance on a Visual C++ program that was already made. The program disabled multiple instance so I could not run serveral of the same windows anymore, and I just want to run serveral of the same windows. For example... msn polygamy.
The program that I want to disable can be downloaded here >> http://quizquiz.nexonasia.com/download/setup.exe
It's a game that I would like to clone. I read on the site about mutliple instances and understood some of it, but I'm not good at programming languages, so I didn't know what to do.
I tried to use a hex editor to find the text string value "Mutex". But I didn't know what to change. All I know is that mutex has something to do with disabling multi instance.
I'd appreciate if someone would kindly help me out. Thanks.
|
|
|
|
|
Are you saying you want to modify the behavior of the binary? That can be done by patching the .exe, but don't even begin to try if you're not handy with x86 assembler and Windows internals.
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|