|
My application need to connect to a time server and retrieve the current time. I have no idea how to do that. Anyone can give me a hint?
RT
|
|
|
|
|
For starters, you can read up on the Time Protocol. Then it's just a matter of writing code to connect to a time server. I'm sure there are plenty of examples out there on how to do this. Just search google, or perhaps even here on Code Project.
[Update] Sorry I can't be of more help right now. I'll try to get back to you in a few hours.
Jon Sagara
I can't think of anything original to say.
|
|
|
|
|
Hi All,
I am considering getting a Windows debug tool such as BoundsChecker (the only such program that I am even a little familiar with).
I am looking for opinions on the usefulness of these tools, and specific recommendations for products. Who are BoundsChecker's competitors? I seem to recall a tool called Purify, but can' really think of much else.
It seems like the market for these tools is diminishing (there aren't even any adds for debuggers in recent issues of MSDN magazine). Is this because the debugger in Visual Studio is good enough?
Any opinions and advice will be greatly appreciated.
Thanks very much,
Sean
|
|
|
|
|
I rely on BC to help out when things get tricky. VC's debugger (at least in VC6) can't catch the things BC can: dangling pointers, resource and global memory leaks, array out of bounds, uninitialized, etc..
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
I use BoundsChecker. For me is all that I need for debug my programs, detect memory leaks, optimization of codes, etc.
I personally think that never will change the bounschecker of other tool.
It's only my opinion.
Carlos Antollini.
When is Friday?
In three days Bob....
|
|
|
|
|
The debugger in VC6 is pretty decent (I wish it would expand macros and reveal the value of constants). Boundschecker sometimes falsely identifies memory leaks, but is good at pointing out where leaks might be occurring in other code (Stingray libraries for instance).
It's a good add-on, but I only use it as a last resort, and as a last resort tool, I don't see it was being worth the relatively excessively high price.
To hell with those thin-skinned pillow-biters. - Me, 10/03/2001
|
|
|
|
|
We used BC for quite a while as a 'final check' of the code, but we no longer use it because of the excessive upgrade costs - each new version is an expensive addition, and the features have changed very little. Since BC 5 doesn't integrate with VC 6, we no longer use it.
-----------------------
The sermon on the mount...
Man 1 : Hear that? Blessed are the greek.
Man 2 : The greek?
Man 1 : Well apparently, he's going to inherit the earth.
Man 2 : Did anyone catch his name?
|
|
|
|
|
BoundsChecker, Purify and other diagnostic tools solve slightly different problems than built-in debugger in VC6. They are used for pinpointing errors like memory/resource leaks and invalid parameters passed to Windows API. The built-in debugger is for watching stack/variables/memory etc. Sure, there's some leak detection built into C/C++ runtime, but it's a basic level only.
I've used both BoundsChecker and Purify - and Purify is my favorite program. However, I think you should check it yourself before spending hard-earned cash. Both programs have free evaluation versions on the web.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
The lack of advertising for BC does not correspond to declining need or demand at all. It is simply the absence of a corporate advertising budget.
|
|
|
|
|
I still have problems with my app.
I am developping an C++/MFC app which might be installed on several language version of NT4 or 2000. This app can change its own language (french, english and german). The problem is that I want to dynamicaly change the language of the resources contained in the mfc42loc.dll without linking statically the MFC DLLs.
The solution I have found is building a resource DLL with the standard MFC resources (afxres.rc, afxprint.rc...) for each language and then laoding the apropriate dll dynamicaly and set resource handle to the App. It works, but I've had to move all my app's resources in the resource DLL to use them. I don't know if it is the best way to do.....
The second problem is about the standard windows of COMDLG32.DLL as "Print setup", "Save as", "Font or color selction"... Is there anybody who find a way to dynamicaly change the language of these boxes ? This app must be able to run in german on a english system!!!
The third one is about the calendar: where are hide the names of the monthes ???? I looked in most of the DLL I didn't find them...
Thanks for help
elisabeth.sever@europlacer.fr
|
|
|
|
|
Hi,
Some ideas for 2) and 3):
2) I think you can't have common dialogs and system dialogs in a language different from the OS's language.
3) Use GetLocaleInfo() with LOCALE_SMONTHNAME1-12 to get the names of the months. You can also get name of tha days and other things with proper flags.
Cheers,
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
Hi,
I've read a few about the .inf file format and the setup API functions and
I'm trying to make a tiny little application for practice. But I couldn't
for my life make something that actually works. I attached you the inf and
the code that deals with it. I hope it will not bore you because I
desperately need enlightenment on what am I doing wrong.
If you don't feel like following the flow, could you please give me a working
example as simple as possible of copying a file through .inf files.
Thank you in advance
UINT CALLBACK EmptyHandler(
PVOID Context, //context used by the callback routine
UINT Notification, //notification sent to callback routine
UINT Param1, //additional notification information
UINT Param2 //additional notification information
);
void CFirstPrinterDlg::OnButtonTestMyInf()
{
// TODO: Add your control notification handler code here
UINT nErrLineNo;
HINF hInfFile = SetupOpenInfFile ("d:\\druckertest\\gogo.inf",
"Printer", INF_STYLE_WIN4, &nErrLineNo );
if( hInfFile == INVALID_HANDLE_VALUE ){
ErrorMessage( "SetupOpenInfFile()" );
if( ERROR_NOT_ENOUGH_MEMORY != GetLastError() ){
CString s;
s.Format( "Error at line no %u", nErrLineNo );
AfxMessageBox( s );
}
return ;
}
if( FALSE ==
SetupSetDirectoryId( hInfFile, 66000,
"d:\\druckertest\\output" )
){
ErrorMessage( "SetupSetDirectoryId()" );
return;
}
/*
BOOL SetupGetSourceFileLocation(
HINF InfHandle, // handle of an INF file
PINFCONTEXT InfContext, // optional, context of an INF file
PCTSTR FileName, // optional, source file to locate
PUINT SourceId, // receives the source media ID
PTSTR ReturnBuffer, // optional, receives the location
DWORD ReturnBufferSize, // size of the supplied buffer
PDWORD Required Size // optional, buffer size needed
);
*/
UINT nID;
TCHAR buffer[ 1000 ];
DWORD required;
if( FALSE ==
SetupGetSourceFileLocation(
hInfFile,
NULL,
_T( "file.txt" ),
&nID,
buffer,
1000,
&required
)
){
DWORD n = GetLastError();
DWORD k = GetLastError();
ErrorMessage( "SetupGetSourceFileLocation()" );
//return;
}
int a;
BOOL bRes = SetupInstallFromInfSection( NULL, hInfFile,
"[INSTALL]", SPINST_FILES, NULL, "D:\\druckertest",
SP_COPY_DELETESOURCE, EmptyHandler,
&a, NULL, NULL );
if( bRes == FALSE ){
ErrorMessage( "SetupInstallFromInfSection()" );
return ;
}
SetupCloseInfFile( hInfFile );
return ;
}
And gogo.inf is:
[VERSION]
Signature="$Windows NT$"
Class = Printer
Provider = LukeNuke
[INSTALL]
CopyFiles = @file.txt
[DestinationDirs]
DefaultDestDir=66000
[SourceDiskFiles]
file.txt = 1
[SourceDiskNames]
1 = "LukeNuke",*.*
|
|
|
|
|
Anyone know how to add a command ID with a set value of 8000? or better still, allocate a set range of command ID's from 8000 to 8049, so that only i can allocate these ID's at runtime? How would I then go about adding dynamic command id's at run-time so that they fall within the specified range? The problem I have is that I am using UINT as a way of assigning a menu item its ID. However, the status bar does not display any text when i move the mouse over the item, nor is there any assurance that that ID hasn`t been used elsewhere in the program, which would cause undesirable results.
Theres definitely a "This helped" going on this one.
AEGC
|
|
|
|
|
What determines the existance of a given menu item? The presence of a DLL? A registry entry?
If it's the presence of a DLL, maybe all your DLL's should have an exported function that can provide the program with the following associated info:
- Menu item ID
- Menu item name
= tooltip text
- status line text
All installed DLL's should be listed in the registry and when the program attempts to call LoadLibrary, each DLL can be queried for the data (as opposed to putting that data in the registry as well). Since you're writing the DLL's, it would be up to you keep the various ID's, names, and text unique, but that shouldn't be too god awful tough.
If it were me, I'd establish (in my app) a minimum ID and a maximum ID so that I could use that range in my ON_COMMAND_RANGE handler. Remember, just because it handles a range of ID's doesn't mean they all have to be used.
Also, I would makes sure that range of command ID's are not used by other resources.
I know this response was a broad contextual overview of the procedure, but you should be able to work with what I've suggested if you're at all experienced in writing DLLs and accessing the registry.
Unfortunately, there's no automatic method for doing what you want to do (compartmentalizing resource ID usage) - it's grunt work that must remain grunt work.
To hell with those thin-skinned pillow-biters. - Me, 10/03/2001
|
|
|
|
|
The command id number is controlled by the resource.h file.
#define _APS_NEXT_CONTROL_VALUE 201
You can modify the value of this constant and new commands will be created with the new base number. If you look in your <projectname>.res file you will see the control ids already defined. These too can be edited. Be careful, however not to bump into system command IDs or other confilcts. Also be aware, the IDE will assign control ids based on the defined constant. So if you just make some up, you mus change the constant to ensure the number won't be reused.
Hope this helps,
Bill
|
|
|
|
|
I believe he wants to generate these ID's at runtime.
To hell with those thin-skinned pillow-biters. - Me, 10/03/2001
|
|
|
|
|
Your are right, I missed that.
Thanks for the help,
Bill
|
|
|
|
|
Once you have used ON_COMMAND_RANGE etc to map where the messages goto, you can use CMainFrame:GetMessageString to provide the status bar prompt and tooltips.
Example code from an app of mine is:
void CMainFrame::GetMessageString( UINT nID, CString& rMessage ) const
{
if (nID >= REFINESCRIPT_MENU_START_ID && nID <= REFINESCRIPT_MENU_END_ID)
{
rMessage = refineDLL[theApp.nIDtoRefineID[nID - REFINESCRIPT_MENU_START_ID]].DLLMenuStatusBarPrompt(nID /*theApp.nIDtoMenuID[nID - REFINESCRIPT_MENU_START_ID]*/) ;
// remove any tooltip
if (rMessage.Find('\n') >= 0)
rMessage = rMessage.Left(rMessage.Find('\n')) ;
}
else if (nID == ID_TOOLBAR_UNDO || nID == ID_TOOLBAR_REDO)
{
// need to get the active document
CDocTemplate *pTemplate;
CRefineDoc *pDoc = NULL ;
POSITION pos;
bool found = false ;
pos = AfxGetApp()->GetFirstDocTemplatePosition();
do {
pTemplate = (AfxGetApp()->GetNextDocTemplate(pos));
POSITION pos2 ;
pos2 = pTemplate->GetFirstDocPosition();
if (pos2 != NULL)
{
// loop through looking for the active docuement
do {
pDoc = (CRefineDoc*)pTemplate->GetNextDoc(pos2);
if (pDoc->m_bActiveDocument)
found = true ; // found it!
} while (!found && pos2 != NULL) ;
}
} while (!found && pos != NULL) ;
if (pDoc != NULL)
{
CString command ;
if (nID == ID_TOOLBAR_UNDO)
{
// get the undo message text
pDoc->GetUndoText(command) ;
rMessage.Format("Undo command \"%s\"", command) ;
}
else
{
// get the redo message text
pDoc->GetRedoText(command) ;
rMessage.Format("Redo command \"%s\"", command) ;
}
}
else
CMDIFrameWnd::GetMessageString(nID, rMessage) ;
}
else
{
// check to see wether the nID is part of one of the loaded toolbars.
// it it is, we need to load the string from that dll's resources
bool found = false ;
for (int i = 0 ; i < m_ToolbarCount ; i++)
{
if (m_pTB[i]->CommandToIconIndex(nID) >= 0)
{
found = true ;
// get the string from the DLL
rMessage = refineDLL[m_DLLIndexes[i]].DLLMenuStatusBarPrompt(nID) ;
// split the text at an \n
if (rMessage.Find('\n') >= 0)
rMessage = rMessage.Left(rMessage.Find('\n')) ;
}
}
if (!found)
CMDIFrameWnd::GetMessageString(nID, rMessage) ;
}
}
In the function:
REFINESCRIPT_MENU_START_ID = start of the command range allocated
REFINESCRIPT_MENU_END_ID = end of comamnd range allocated
The above code is used in a project where dynamically loaded DLL's are used, which also add menu options etc in. New toolbars may also have been added to the UI.
Hope its of help.
BTW GetMessageString is a virtual function you can override
|
|
|
|
|
I'd use AfxExtractSubString (just like MFC does) for extracting status bar prompt
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Can anyone please tell me how to make a CFormView object to
a non resizable window?
Thanks.
Aviv.
avivhal
|
|
|
|
|
Override the OnSize() message in your view and just don't pass the message on to the base class.
You may have to have a variable that indicates that the window is being initialized so that you can pass the size info along, and NOT to pass it along any other time.
1) Define a private boolean var in your class definition like so:
BOOL m_bAllowResize;
2) In the view constructor, do this:
m_bAllowResize = TRUE;
3) At the end of OnInitialUpdate() do this:
m_bAllowResize = FALSE;
4) In your OnSize function, do this:
if (!bAllowResize) { return; }
I haven't tried this, and you may have to try moving some of the code I listed above around in the class, but in theory, this should be close to what you want.
To hell with those thin-skinned pillow-biters. - Me, 10/03/2001
|
|
|
|
|
Hi,
I used these functions in a demo project:
void CDemoView::FormViewToDialog()
{
CWnd* pParent = GetParent();
CRect rect;
GetTotalClientRect(&rect);
DWORD style = pParent->GetStyle() & ~WS_THICKFRAME | WS_DLGFRAME;
::AdjustWindowRect(&rect, style, ::IsMenu(::GetMenu(pParent->GetSafeHwnd())));
ModifyStyleEx(WS_EX_CLIENTEDGE, 0);
pParent->ModifyStyle(WS_THICKFRAME, WS_DLGFRAME);
pParent->SetWindowPos(NULL, 0, 0, rect.Width(), rect.Height(),
SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_FRAMECHANGED);
}
void CDemoView::DialogToFormView()
{
CWnd* pParent = GetParent();
CRect rect;
GetTotalClientRect(&rect);
DWORD style = pParent->GetStyle() & ~WS_DLGFRAME | WS_THICKFRAME|WS_CAPTION;
::AdjustWindowRectEx(&rect, style, ::IsMenu(::GetMenu(pParent->GetSafeHwnd())),
WS_EX_CLIENTEDGE);
ModifyStyleEx(0, WS_EX_CLIENTEDGE);
pParent->ModifyStyle(WS_DLGFRAME, WS_THICKFRAME|WS_CAPTION);
pParent->SetWindowPos(NULL, 0, 0, rect.Width(), rect.Height(),
SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_FRAMECHANGED);
}
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
Ahhh, I knew someone would post the right way to do it.
To hell with those thin-skinned pillow-biters. - Me, 10/03/2001
|
|
|
|
|
Always happy to help.
Thanks John!
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
Christian, your last message was
>>The thing you have to consider is, what do you want to achieve ? The way
>>you're writing the file, you're getting an 8 bit greyscale image, if you
>>put this info into an 8 bit bitmap with a palette that went evenly from
>>0,0,0 to 255,255,255, it would work. You're only writing out one colour
>>value as far as I can see, and you're now correctly calculating the grey
>>value. Therefore making your bitmap 8 or 16 bit internally will only result
>>in messy calculations to get to the same point you're reaching now. Please
>>correct me, but I believe you're writing out one unsigned char per colour,
>>although you're making the variable an unsigned long, it will still be
>>between 0 and 255, yes ?
Yes, it still between 0...255.
And more, i compared it for 24 and 32 bpp with using GetPixel function
BYTE grayValue = (BYTE)(int)((GetRValue(clr) + GetGValue(clr) + GetBValue(clr)) / 3),
and it was the same.
But for 8 bitmap, then i using GetPixel it was like
125 125 125 (Red Green Blue)
and for my code it was
31 31 31
Why? I don't know
Yes, i need grayValue for every pixel
But i don't neen GetPixel(), because it work with handle (hDC, DC and other),
i need information only from bitmap (avi frame->LPBITMAPINFOHEADER)
But i haven't ideas how to wrote simple code for 8 and 16 bpp
|
|
|
|
|