|
the 1st character is at index 0, so, the index retrieves the (n-1)th character... is it that hard to understand ?
|
|
|
|
|
|
Try this code
its working
no change in previous code
#include "stdafx.h"
#include <stdio.h>
#include <iostream.h>
#include "stdlib.h"
#include <string.h>
int main(int argc, char* argv[])
{
char* buffer;
//then some memory is allocated with:
buffer=(char *)malloc(10);
//then some text is placed here:
strcpy(buffer, "some text");
char c;
for(int i(0);i<10;i++)
{
c=*(buffer+i);//return each character from the buffer
cout<
|
|
|
|
|
Thank you all for your helpful answers
--PerspX
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
|
|
|
|
|
i have used a text box in my dialog box in WIN32 programming....now i want that the data entered by user can be copied to a text file on pressing ok. what method can i use for this??
|
|
|
|
|
with GetWindowText(...) you can fetch the text and then write it to a file.
Greetings from Germany
|
|
|
|
|
|
To complete your task, have a look also at
CreateFile, WriteFile, CloseHandle WIN32 functions.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
I realise he's using Win32 ( I suspect simply because he has the express edition ), but he's not using C. What's wrong with file streams ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: What's wrong with file streams ?
Nothing, actually.
On the other hand, plain WIN32 API isn't that bad.
As matter of personal taste, I prefer plain C I/O API (fopen ,...) whenever my application is, by design, not OO (for instance, simple test applications).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Use any of the below to retrive text from your edit box
CString strWindowText;
editBoxObject.GetWindowText(strWindowText);
GetDlgItem(ID_OF_THE_EDIT_BOX)->GetWindowText(strWindowText);
then create an CStdiofile object
then the WriteString(strWindowText) function of CStrdiofile to save the text into disk
Rgds
Sivan
http://www.ktsinfotech.com
|
|
|
|
|
He's using Win32, this is MFC code.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hey,
please help me. I've written a ActiveX-Control. How can I transfer data between the control and propertypage. I know the DDP Makro, but with this makro I can only transfer values from controls. I need to transfer "calculated" value. Is there a function to store/transfer data from propertypage to the membervars in the control?
|
|
|
|
|
Hi All,
I want to detect which antivirus and firewall is installed on my computer.
What all I know is WMI can be used, but don't know the Interface or function.
Thanks.
|
|
|
|
|
I also suggest to take a look to the registry, it contains the required informations.
|
|
|
|
|
I'm using the familiar CString in my project. When I see its definition I see it as the following
typedef ATL::CStringT< TCHAR, StrTraitMFC_DLL< TCHAR > > CString;
in the file afxstr.h.
I was thinking what CString has to do with ATL here?
|
|
|
|
|
well, it IS part of the ATL namespace... :p
|
|
|
|
|
MFC CString is typedefed as typedef ATL::CStringT< TCHAR, StrTraitMFC_DLL< TCHAR > > CString;
Come online at:-
jubinc@skype
|
|
|
|
|
Starting with VC7, some utility classes were changed to be shared between ATL and MFC to reduce code duplication.
|
|
|
|
|
Suppose I have a HWND from enumerating the top level windows, how can I replace the Device Context of the drawing process of this window, so that I can get a snapshot of this window?
|
|
|
|
|
Do you want to draw on the window of other programs?
|
|
|
|
|
No, I want to get a snapshot of another application, for example, to make a album of all the running applications
|
|
|
|
|
I tried to use CWnd::GetDC(), and select a CBitmap created by my own, then call CWnd::RedrawWindow(), after that, I suppose the content in CBitmap should be the window, but it failed.
|
|
|
|
|
This isn't tested, or even compiled, just quickly typed up...
CClientDC dcOther (GetDesktopWindow ());
CRect rc;
::GetWindowRect (hWndToClone, &rc);
CBitmap bmpTemp, *bmpOld;
CDC dcClone;
dcClone.CreateCompatibleDC (&dcOther);
bmpTemp.CreateCompatibleBmp (&dcOther, rc.Width (), rc.Height ());
bmpOld = dcClone.SelectObject (&bmpTemp);
dcClone.BitBlt (0,0, rc.Width (), rc.Height (), &dcOther, 0,0, SRCCPY);
dcClone.SelectObject (bmpOld);
and now dcClone should hold a copy of the contents of the first window - or at least what it shows on the screen.
You should look at the very useful article by PJ Arends: Image Viewer[^].
Good luck,
Iain.
|
|
|
|
|
Really thanks, I tried this, the rect is right, but the contents is from the corresponding top level windows, do i need to bring the window to top, and then use this method, but if so, the orders of the windows will be totally ruined.
<br />
CDC dc;<br />
CDC* pDC = pWnd->GetDC();<br />
CRect rc;<br />
pWnd->GetWindowRect(rc);<br />
dc.CreateCompatibleDC(pDC);<br />
CBitmap bmp;<br />
bmp.CreateCompatibleBitmap(pDC, rc.Width(), rc.Height());<br />
HBITMAP bmpOld;<br />
bmpOld = (HBITMAP)dc.SelectObject(bmp);<br />
dc.BitBlt(0, 0, rc.Width(), rc.Height(), pDC, 0, 0, SRCCOPY);<br />
CxImage imgSnapshot;<br />
imgSnapshot.CreateFromHBITMAP(bmp);<br />
|
|
|
|