|
Thanks for this satisfying answer. Yes I think you're right that this important function has to be reached more simple.
|
|
|
|
|
How can I set a Font to a CWnd object with SetFont ?? I try with method GetLogFont, but I don't know how to build a LOGFONT object. Please if you could give me an example... (For Example: Tahoma, size 12).Thank you.
MaestroProgramador.Com
Where every source code is loved like a girl.
|
|
|
|
|
Try this:
<br />
CFont tahomaFont;<br />
<br />
tahomaFont.CreatePointFont(120, "Tahoma");
YourCWndObject.SetFont(&tahomaFont);<br />
That should work. A really good idea is to store your font objects as member variables of a class so you can clean up after yourself at the destructor phase.
Hope this helps
www.kinkycode.com
[Glossary Manager] [AfterThought Backup Lite]
99 little bugs in the code, 99 little bugs,
Fix 1 bug, recompile....
101 little bugs in the code...
|
|
|
|
|
Thank you so much, it was very helfully. It sent me an assert error, but I solved it with:
<br />
CFont* my_font = new CFont;<br />
<br />
my_font->CreatePointFont(120, "Tahoma");<br />
Thank you so much !!
MaestroProgramador.Com
Where every source code is loved like a girl.
|
|
|
|
|
I have been asked to write some sort of media streaming application to work over a network i.e. client / server to demonstrate the various quality of service mechanisms avaliable via the winsock2 gqos api but i've no idea what the best way to go about this would be. Any suggestions, or ideas would be greatly appriciated as to the possible structure of such a program. Cheers.
|
|
|
|
|
Hey guys, thanks in advance for checking this out and would like to apologize in advance considering we still have fairly little direction with this project. On that note: we're making an inventory program, with a client computer updating a database of some kind on the server through a network of some kind.
Now the questions: What network type do you guys think would be best - ADO, DCOM, RPC etc.?
What databasing system do you think would be best? This project is still in its initial phases so let your imagination run wild.
Oh as far as user input, considering the large amount of input that will need to be catalogued, we were considering XML or MFC rather than DOS input.;)
Sorry, feel free to give your input and we'll clarify exactly what were looking for later. Thx in advance.
|
|
|
|
|
|
Sounds like a pretty standard database application. Given a choice I would use C#/VB.Net with ADO.Net for this project, as these kind of "CRUD" applications are easily built using the .Net environment.
ADO to connect to the database server, no need to build complex DCOM components and environments, given the basic requirements you outline.
In C++, I always use MFC as an interface tool, generic Windows API coding is overkill, also WTL is a choice advocated by many, but I am more familiar with MFC, so tend to use this.
XML would not be used to build your interface (unless you are wanting to describe you dialogs in XML??) , but you might want to make an XML importer to allow you to bulk import your data.
SQL Server will do nicely as a db server in an MS environment, it will also allow you to build stored procedures. This is given you have the budget however!!
For projects with no budget, I am a great fan of MySQL as a database server, but you do loose stored prodcedure support. PostgreSQL is also an excellent free-software choice, and offers views&stored procs as well (though I cannot say how well, as I am not a PostgreSQL fundi)
HTH
Mark
Windows, Linux and Internet Development Consultant
Email: corporate@scriptsmiths.com
Web: http://www.scriptsmiths.com
|
|
|
|
|
I know I asked about this a few weeks ago, and someone was kind enough to supply me with some (still untested) code:
CMyDialog::doMaximize()
{
CRect rect;
GetParent()->GetClientRect(&rect);
ClientToScreen(&rect);
MoveWindow(&rect);
}
I was wondering what message had to be sent in order for this bit of code to get executed? The only ones I could think of using were WM_SIZE or WM_MOVE but I really don't think they're what I want. I tried handling the WM_SIZE, but it didn't do exactly what I'd like it to have done.
|
|
|
|
|
Have you tried putting it in OnInitDialog?
|
|
|
|
|
By putting it in OnInitDialog, wouldn't that start the dialog out maximized? I want it to maximize like that only when the user clicks on the maximize button up in the top corner of the dialog, otherwise I want it to remain the size it was when it opened initially (and also be able to be minimized)
|
|
|
|
|
This might seem as a strange question and a bit off topic, but I really need the official name of the '|' character/key.
Is it 'dash'?
|
|
|
|
|
I think it officially is 'bar' but I've also heard it described as 'pipe'
|
|
|
|
|
According to the character map utility it is called Broken Bar. Whether it is broken or not depends upon what font you select, though.
Chris Meech
It's much easier to get rich telling people what they want to hear. Chistopher Duncan
Why do people in this time period worry so much about time traveler's destroying their worldline when they have no problem doing it themselves every day? John Titor
|
|
|
|
|
Vertical bar, or 'pipe' from my days in the Unix world.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
DavidCrow wrote:
'pipe' from my days
pipe from your days in the strip club world you man-whore. =)
Lol sorry man couldnt resist.
|
|
|
|
|
I call it the 'pipe' char, after the MSDOS days of command prompt control. (ahhh, those were the days)
I Dream of Absolute Zero
|
|
|
|
|
There's no way this is the first time someone has encountered this but all of my searches are turning up unrelated crap.
I have a CRichEditCtrl in a dialog (modal) that I want to be able to accept the TAB key. The dialog keeps butting in and stealing the TAB (as it normally would) to select the next control. There are no other controls that I would want to jump to so if there is a solution that will allow me to get the TAB key within the edit and not have the focus change, that would be ideal.
I have tried playing with PreTranslateMessage() and a few other things but the focus continues to change not matter what I have tried.
Thanks for any help you may be able to provide.
Dave
|
|
|
|
|
Check WM_GETDLGCODE documenation.
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
Thank you very much! That did it!
|
|
|
|
|
hello ppl
i am a newbie to socket programming i am having problems in connecting a client to a server. This is what my SERVER code looks like :
int MainFrame ::OnCreate(LPCREATESTRUCT lpcs)
{
if(!AfxSocketInit())
MessageBox("Socket init error");
//create the server first
if(server.Create(1000,SOCK_STREAM))
MessageBox("Server Socket Created");
CWnd::SetTimer(1,1000,0);
return CWnd::OnCreate(lpcs);
}
void MainFrame::OnTimer(UINT nIDEvent)
{
if(!server.Listen())
MessageBox("Server not responding");
CWnd::OnTimer(nIDEvent);
}
What this code tries to do is that it creates a server on PORT 1000 and listens for incoming connections after each second
now the second part that is the CLIENT has the following code
int MainFrame ::OnCreate(LPCREATESTRUCT lpcs)
{
if(!AfxSocketInit())
MessageBox("Socket init error");
if(client.Create(2000,SOCK_STREAM))
MessageBox("Client Socket Created");
return CWnd::OnCreate(lpcs);
}
void MainFrame ::OnConnect()
{
while(client.Connect("172.16.64.89",1000) != TRUE )
client.Connect("172.16.64.89",1000);
MessageBox("Connected to Server");
}
Everything goes fine here except when i am trying to listen to the server using Connect it never suceeds
please help me out whats wrong with my code what modifications are to be made will be very much thankful
Regards
Cyberizen
|
|
|
|
|
I'm not 100% familiar with CAsyncSocket (this is what you are using?), but this tips might help/be applicable, but do take it with a pinch of salt!!
1. I don't think you have to "Listen" repeatedly, just call Listen() once
2. You need to Accept() connections in you server, implement the OnAccept() notification
3. You shouldn't bind you client socket to a specific port, rather use Create() and let the socket pick the best port for the client
4. Don't use ports in the 0-1024 range, these are resevered, rather us a number > 7000, this is what I usually do.
So maybe:
class CMySocket : public CAsyncSocket
{
CSocket m_Client;
protected:
virtual void OnAccept(int)
{
Accept(m_Client);
}
}
...
//in MainFrame
CMySocket server;
...
int MainFrame ::OnCreate(LPCREATESTRUCT lpcs)
{
if ( !AfxSocketInit() )
{
MessageBox("Socket init error");
}
//create the server first
if ( server.Create(7000,SOCK_STREAM) )
{
server.Listen();
MessageBox("Server Socket Created");
}
return CWnd::OnCreate(lpcs);
}
>>now the second part that is the CLIENT has the following code
int MainFrame ::OnCreate(LPCREATESTRUCT lpcs)
{
if ( !AfxSocketInit() )
{
MessageBox("Socket init error");
}
if ( client.Create() )
{
MessageBox("Client Socket Created");
}
return CWnd::OnCreate(lpcs);
}
// OnConnect is a method delacared in your mainframe
// and called by you in some way, maybe in response to
// a menu item, etc DONT FORGET TO CALL THIS METHOD!!!
void MainFrame ::OnConnect()
{
// this is nasty!! there should be a delay of some kind
// or perhaps some other mechansim, if the connection fails
// this will just flood the poor server!!
// what if it never succeeds? You app will just lock up and the
// MMI will cease to respond!
while ( client.Connect("172.16.64.89",7000) != TRUE )
{
client.Connect("172.16.64.89",7000);
}
MessageBox("Connected to Server");
}
Windows, Linux and Internet Development Consultant
Email: corporate@scriptsmiths.com
Web: http://www.scriptsmiths.com
|
|
|
|
|
I need help trying to programmatically print in landscape mode use Windows 2000. The code below works on Windows 9x but not on Windows 2000:
...
printerDC.StartPage();
DEVMODE dm;
memset(&dm, 0, sizeof(dm));
dm.dmSpecVersion = DM_SPECVERSION;
dm.dmSize = sizeof(DEVMODE);
dm.dmFields = DM_ORIENTATION;
dm.dmOrientation = DMORIENT_LANDSCAPE;
printerDC.ResetDC(&dm);
... Under Windows 2000 the page is printed portait mode.
I have looked in the MSDN, no help...
Thanks in advance!
Jonathan Craig
www.mcw-tech.com
|
|
|
|
|
You don't want to do that. DEVMODE is a standard structure but there are cases where the printer driver needs additional space.
You should get the existing DEVMODE and modify that in-place (or possibly copy that, including allocating any extra space).
Steve S
|
|
|
|
|
Hi, I get times from a server given in UTC (Coordinated Universal Time or Universal Time Coordinated),
that is similar to GMT (Greenwich Mean Time) but not adjusted to daylight saving time. That is, during
summer, UTC differs one hour from London time, since UK uses daylight saving during summer.
The application I develop is used worldwide so I can not assume or hardcode anything. This should not
be a problem since winapi have functions to handle this. I do the following.
The function I use to convert UTC time to local time (New York time for me) looks like this:
COleDateTime ConvertToLocalTime(const COleDateTime& timeUTC)<br />
{<br />
<br />
_tzset();<br />
<br />
<br />
CString str;<br />
str.Format("offset = %d, daylight = %d, %s, %s\n", _timezone, _daylight, _tzname[0], _tzname[1]);<br />
cout << (LPCTSTR)str<< endl;<br />
<br />
<br />
COleDateTimeSpan timeSpanOffset(0, 0, 0, _timezone);<br />
<br />
COleDateTime timeLocal = timeUTC - timeSpanOffset;<br />
<br />
<br />
str.Format("time UTC = %s, time local = %s", timeUTC.Format("%H:%M:%S"), timeLocal.Format("%H:%M:%S"));<br />
cout << (LPCTSTR)str<< endl;<br />
<br />
return timeLocal;<br />
}
and produces the following output:
offset = 18000, daylight = 1, Eastern Standard Time, Eastern Daylight Time
time UTC = 11:23:45, time local = 06:23:45
Five hour difference which is fine during winter time, but when daylight saving is in effect, it only differs
four hours. Windows apperently handles this fine, the clock in the notification area adjusts properly, but is
there some way from the API to find out if daylight saving is in effect or not? Are there other ways than using
the functions I been using? _daylight only tells you if Windows should adjust for daylight saving or not.
Disabling automatic adjust of daylight saving in the Windows clock only affects the output as follows:
offset = 18000, daylight = 0, Eastern Standard Time, Eastern Standard Time
time UTC = 11:23:45, time local = 06:23:45
Thanks, Mellowman
|
|
|
|
|