|
Some thing like that.
Basicaly (GDI using MFC):
1) CDC dcMem;
1) dcMem.CreateCompatibleDC(NULL);
2) CBitmap* pOldBmp = dcMem.SelectObject (your_bitmap);
3) dcMem.TextOut(x,y,pStr);
4) dcMem.SelectObject(pOldBmp);
The original bitmap has now been modified and can be saved, with changes.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Thanks!
I'm try it, but there is an error:
CBitmap* pOldBmp = dcMem.SelectObject (your_bitmap);
error C2440: 'initializing' : cannot convert from 'void *' to 'class Gdiplus::CBitmap *'
What's the matter?
|
|
|
|
|
I used your code, but the TextOut didn't display the text, and didn't save it. What's the matter?
|
|
|
|
|
Well, I expected you to do a little reseach (not depend on just what I said [although is was correct]).
What I gave you, would change the bitmap stored in memory. It, of course, did not save anything. After you have changed the bitmap, how you save it is up to you. A non-C++ call to TextOut is (would be):
TextOut(hdc,x,y,lpString,cbString); // where cbString is number-of-characters.
Please do us and your-self a favor: Post a minimum example, that shows what the problem is.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Hello,
Is there is any Windows Equivalent of these Runtime Function memset(), isdigit(), malloc(), realloc(), atoi().....
any Article or Link related to this would be Very Great Help!!!
[Vote One Here, Complete my Survey....]
Alok Gupta visit me at http://www.thisisalok.tk
"I Think Believe this Will Help"
|
|
|
|
|
I am not sure I understand your questions as these functions exist in "Windows" and if by this you mean Visual C++.
Hope this helps,
|
|
|
|
|
Hope So,
Actually these function which I have mentioned above i.e. atoi ,memset etc are defined in MSVCRT.dll I just looking for windows equivalent for these function.
For e.g. equivalent of strcmp in windows is lstrcmp .now, you must be wondering why I required that, first to reduce dependency of MSVCRT.dll and second reduce the size of executable .
[Vote One Here, Complete my Survey....]
Alok Gupta visit me at http://www.thisisalok.tk
"I Think Believe this Will Help"
|
|
|
|
|
ThatsAlok wrote:
...to reduce dependency of MSVCRT.dll...
Which is really just a misnomer. You either have a dependency on a DLL or you don't. There is no in-between (i.e., reduce). If you use even one exported function from a DLL, the DLL in its entirety is mapped into the address space of your application. And since MSVCRT.DLL is probably already mapped to other applications, one more is irrelevant.
To get a better understanding of file and process sizes and how they differ, I suggest reading this article.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
|
ThatsAlok wrote:
reduce dependency of MSVCRT.dll
I'm pretty sure lstrcmp() ends up calling strcmp() .
[edit]
I was wrong. lstrcmp() is contained in kernel.dll . It's a separate function because it works differently from strcmp() .
[/edit]
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
It is very hard to get away from the MSVCRT.dll, since many (if not most) libraries depend on it. Therefor, you will probably be dependent on it even if you do not call any of the standard C-functions that it contains.
When designing a COM control: You have the option of defining minimum dependencies, which attempts not to include MSVCRT.dll, but I have never been able to eliminate that dependency my self.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
|
In the UK - and in most of Europe as well - we have lost an hour over the week-end. We get used to it and Windows usually handle it pretty well but... I have a client whose date / time is indicated properly in the task bar but COleDateTime::GetCurrentTime returns the time -1 hour (the old time - the GMT one).
Restarting the application does not change anything.
Any idea about what could cause this?
Should I mention it happens on a Novell network ot is this a red herring?
Thanks in advance for any help.
|
|
|
|
|
The administrator found the problem. I give his answer for future reference.
"Our W2K servers do not synch their time from Novell network, they synch their time from PDC, which synchronises itself using NTP. Our Novell network synchronises itself from the same NTP source as well. Neither W2K nor Novell has the ability of peering through NTP - they are both just synching themselves of an NTP source. All servers and workstations are displaying the correct time on the system tray or similar - and that might be something that baffled everyone.
The culprit for the error was a legacy environment variable TZ with its value set to GMT0, as required by Surveycraft since the day one. Surveycraft does all time zone difference calculations itself as the MS C-libraries were quite buggy on that respect in the mid 80's. To be able to do it properly Surveycraft required the TZ to be GMT0.
During the winter that did not make a difference, since the GMT0, or UTC as it should be called, was the same as the local time. Now, since the local time is UTC+1, there is an hour difference between the local time and GMT0, but the localtime was returning a time instructed by the TZ, a GMT0 time.
Removing setting of legacy environment variable TZ from the login script corrects situation here, but also cripples Surveycraft operations with CATI during the daylight saving time (should there be ever need for such a thing). A quick test indicated that Surveycraft and AskiaVoice were only applications affected by changing of the value of TZ environment variable - every other one tested returned the same value for current time regardless of the existence of TZ environment variable or its value."
|
|
|
|
|
Surveycraft should probably have been using gmtime(), not localtime(). gmtime() always returns the current UTC time. localtime() uses TZ if it's set and falls back on the Windows settings if it's not.
Most Windows applications will use GetSystemTime (returns UTC) or GetLocalTime (returns the current time in the time zone selected in Control Panel/Date and Time), rather than the C run-time libraries.
An additional issue is that DOS stored the local time in the hardware clock. It did not have any native support for Daylight Savings Time. When asked for UTC [gmtime(), time()], the DOS C run-time would convert back from local time (with the inherent flaws around the Daylight Savings start and end dates). Windows inherits keeping the hardware clock in local time, for compatibility, but only reads it at boot time, converting to UTC. It then maintains the clock in memory without reference to the hardware clock, relying on interrupts to update the in-memory clock. The hardware clock is, I think, only updated when the time zone changes or the date and time are set explicitly (either by the user or by the NTP client), and also on system shutdown.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Thanks for this... and I have just read your article which is very useful as well!
|
|
|
|
|
I had written an application in a language version. All displaying strings in my application were written in this language in the string table.
Now, How could I add support for other languages without modifying the existed resources?
Is it possible to be done by adding resources such as string table in other languages?
What should I do to use resources of the specified language and let the IDE build an application of specified language?
I'll appreciate your help, thanks~~!
|
|
|
|
|
|
Hi, I need to get the domain name (not the controller domain name) of a remote computer. I'm using NetWkstaGetInfo function and I tried to use it, but I have got problems. This function works correctly when I try to get domain name of local computer but it returns an error when I tried to get information about a remote computer. This is the function code:
BOOL GetDomainName(char *szTerminal, char *szDomain)
{
PWKSTA_INFO_100 pBufferInfo;
NET_API_STATUS err = 0;
DWORD dwBytes;
WCHAR *swzTerminal = NULL;
dwBytes = MultiByteToWideChar(CP_ACP, 0, szTerminal, -1, NULL, 0);
swzTerminal = malloc(dwBytes* sizeof(TCHAR));
dwBytes = MultiByteToWideChar(CP_ACP,
0,
(LPCSTR)szTerminal,
-1,
swzTerminal,
dwBytes);
err = NetWkstaGetInfo((char *)swzTerminal,
(DWORD)100,
(LPBYTE *)&pBufferInfo);
if(err != NERR_Success)
{
return FALSE;
}
WideCharToMultiByte(CP_ACP,
0,
(LPCWSTR)pBufferInfo->wki100_langroup,
-1,
szDomain,
MAX_PATH,
NULL,
NULL);
return TRUE;
}
The returned error is err = 5 (ERROR_ACCESS_DENIED)
I read some Microsoft information about privileges required for executing this function. But I executed the program with an local administrator user in Windows 2K and NT and got the same problem. I just need information about the domain name, not modify anything. Maybe is there a posiblity of querying information with a lower level that don't require administrator privileges.
I've seen some commercial programs (like Dameware) that obtains the domain name just with IP address of remote computer, without establishing any connection (and introducing username and password). I am trying to do the same.
In the NetWkstaGetInfo information appears:
"You must have Print or Server operator privilege, or be a member of the Administrator or Account local groups to successfully execute NetWkstaGetInfo at level 0 or level 1 on a remote server. No special privilege is required for level 10 calls."
How can I do level 10 calls?
Thanks.
|
|
|
|
|
In my application, com component created a window which is not a com object(for example: CWindow ), and has a method to get the window's HWND.But I want to show the window in MFC's Splitter view.
I try to attach Splitter view to the window, but failed. who can tell me how to do this, thanks very much.
hdfhfgh
|
|
|
|
|
Hi
I'm using CHtmlEditCtrl to edit HTML documents.
The following code is used to load the file into the document object. It works fine when the document is initally loaded, but once the file has been edited and saved by the document object itself, the file does not load correctly.
I'm not to hot on reading from files, so any suggestions would be appriciated.
Many Thanks
Mark
if(f.Open(m_sEditingFile, CFile::modeRead))
{
while(f.ReadString(sIn))
{
SAFEARRAY* psa = SafeArrayCreateVector(VT_VARIANT, 0, 1);
VARIANT *param;
SafeArrayAccessData(psa, (LPVOID*)¶m);
param->vt = VT_BSTR;
param->bstrVal = sIn.AllocSysString();
pDoc->writeln(psa);
}
}
|
|
|
|
|
All
Found my own answer...
IHTMLDocument2 *pDoc;
if(m_pHtmlEditCtrl->GetDHtmlDocument(&pDoc))
{
LPDISPATCH lpDispatch = NULL;
IPersistFile *lpPersistFile = NULL;
// m_ctrl is an instance of the Web Browser control
pDoc->QueryInterface(IID_IPersistFile, (void**)&lpPersistFile);
lpPersistFile->Load( sFilename.AllocSysString(),0);
lpPersistFile->Release();
}
This came from code I found documented to save the file. A quick check and the IPersistFile did include a "load".
The thing that gets me is "where is this documented", they are all MS controls yet I can't find any of this on the MSDN site. I spent more time looking for examples of code and objects than I do designing the software and coding....
How the above code is a help to anyone else playing with these controls.
Mark
|
|
|
|
|
Hi
This is the basic layout of what I am doing:
(1) I have created a CPropertySheet() class that has a few CPropertyPages added to it. The CPropertySheet is set in wizard mode.
(2) For some CPropertyPage instances of CPropertyPage, the OnWizardNext determines which page will be viewed next. I thought that this should be simple enough and I can call (CPropertySheet*)GetParent() from CPropertyPage and then call CPropertySheet::SetActivePage with the page number that should be viewed next.
However, this does not work and I am not sure how and where SetActivePage() should generally be called from. The Visual C++ docs on this topic are sparse. If someone has used SetActivePage before or knows a clean way to change the ordering of the pages in a property sheet, please reply.
Thank you
|
|
|
|
|
|
In your CPropertyPage derived class, override OnWizardNext() and return the id of the CPropertyPage to be displayed. You can also return 0 for the default next page or -1 to prevent the wizard from advancing.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|