|
That'd do it, thanks. Didn't i tell you it was an easy question.
|
|
|
|
|
use std::ifstream::getline()
|
|
|
|
|
Thanks for you help at first!
I'm a chinese student and my english isn't very well! A I really want your can give me some help on my english and computer courses(I'm very interesting in Visual C++)!
I'm a tenderfoot about C++ language!
I'm confusing by the question as follows:
there is parts of my code:
int a=10;
int* ap=&a;
char c='b';
char* cp=&c;
when I want to get the vaule of the Pointers point to;
cout<
|
|
|
|
|
Yeah, i got garbage as well, except i had a whole array of chars (an entire 7) to get round the problem, i had to write out each character at a time, a bit much effort really
|
|
|
|
|
you get garbage values after the character 'b' because the operator << is overloaded for a code char* parameter, to be a C-style string.
such a string is supposed to be NUL terminated (with '\0' ), so it read from the beginning (the 'b' character) until it finds a '\0' character in the memory after the 'b' , even if it is not yours.
if you want to see the address of the pointer, do this :
cout << (const void*)cp;
-- modified at 12:01 Tuesday 31st October, 2006
|
|
|
|
|
wanlim0817 wrote: ...Is there some differences between the int* type and cahr* type?
Of course. One points to an int and the other points to a char .
wanlim0817 wrote: And why there are some garbage gets when I use "cout<<cp"!< blockquote="">
Did you look to see what << operator was being called?
cout << (const void *) cp;
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
David, just a personal wondering, but here, is there a reason to use (const void*) more than the non-const (void*) cast ?
i don't see anything serious, so maybe you could light me up...
|
|
|
|
|
toxcct wrote: ...is there a reason to use (const void*)...
It matches the method's signature.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
obviously
I didn't think that far. thanks
|
|
|
|
|
I always receive following error when compile the win32 vs project written in C. But I checked the makefile and couldn't find any variable at the left of the equal sign is not defined.
Any suggestions???
------ Rebuild All started: Project: f1, Configuration: Debug Win32 ------
Performing Makefile project actions
Microsoft (R) Program Maintenance Utility Version 7.10.3077
Copyright (C) Microsoft Corporation. All rights reserved.
NMAKE : fatal error U1063: missing macro name before '='
Stop.
Project : error PRJ0019: A tool returned an error code from "Performing Makefile project actions"
|
|
|
|
|
Can you whittle the makefile down to just the lines necessary to reproduce the problem? Is the macro name being complained about itself a macro that expands to nothing?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi all,
I am using a CFile class to work with a file and I would like it to retain its original date and time setting. I obviously forgot what to use to get and set the date and time of a file. Pease help (I seem to remember that I should not use the CFile class itself but maybe do something with CFileFind; however this gets a file date and time, but does not set it)
Thanks in advance,
William
|
|
|
|
|
Why are you not using CFile::SetStatus() ?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thanks,
That was indeed the one I forgot about.
Regards,
William
|
|
|
|
|
Hi All,
I just in between of a project.. i need to add some menuitem in the default cut,copy,paste menu.. but problem is that i am not able to get Handle to the Menu so that.. i can add my new sub item...
Could someone give me some pointer to solve this problem.. in brief i want to extend the default Right Click Cut,Copy,Paste menu which come when you right click on any EDIT Box in unmanaged VC++
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief And You
|
|
|
|
|
I know your problem and I think I saw an example that insert items to right click on editbox but i dont know its on www.codeproject.com or www.codeguru.com I search for it if I found I reply to you
|
|
|
|
|
WhiteSky wrote: but i dont know its on www.codeproject.com or www.codeguru.com I search for it if I found I reply to you
my search is't fruitfull today, might be yours
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief And You
|
|
|
|
|
|
WhiteSky wrote: How to modify a CEdit context menu[^]By Mr PJ Arends.
thanks hamid!.. that i am looking for.. thanks a ton!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief And You
|
|
|
|
|
I glad that your problem solve
|
|
|
|
|
I think that you will have to override the right-click/WM_CONTEXTMENU and provide your own. I do not think it is possible to directly modify the the edit control's menu because I think that menu is built-into the edit control and is a standard feature of Win32 (ever since Win2K or Win9x, I believe).
A global hook can simulate a modification to the shared menu...
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
James R. Twine wrote: I think that menu is built-into the edit control and is a standard feature of Win32 (ever since Win2K or Win9x, I believe).
I tried that, but no use?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief And You
|
|
|
|
|
Hello everybody
I am trying to launch "An All-Purpose Keyboard Hook"(http://www.codeproject.com/system/KeyHook.asp[^]) dll with my application, but not successful... I have no idea why dll doesn't post messages to my application. This is a source code:
***Thread.cpp***<br />
<pre>#include "stdafx.h"
#include "ThreadsApp.h"
#include "KeyHook.h"
IMPLEMENT_DYNCREATE(Thread, CWinThread)
Thread::Thread(){ theApp.FileWrite("Thread constructed\n"); }
Thread::~Thread(){ theApp.FileWrite("Thread destructed\n"); }
BOOL Thread::InitInstance()
{
InstallKeyHook();
KEYENTRY m_entry;
m_entry.nMessage = WM_MYTHREADMESSAGE;
m_entry.hCallWnd = (HWND)Thread::m_hThread;
m_entry.hHookWnd = 0;
m_entry.iCombKeys = 0;
m_entry.iIndicators = 0;
m_entry.iKeyEvent = 0;
m_entry.iMinVKCode = 0x00;
m_entry.iMaxVKCode = 0xff;
if(AddKeyEntry(&m_entry) != KH_OK)
{
theApp.FileWrite("AddKeyEntry failed\n");
return TRUE;
}
theApp.FileWrite("Thread initialized\n");
return TRUE;
}
int Thread::ExitInstance()
{
theApp.FileWrite("Thread clean up\n");
return CWinThread::ExitInstance();
}
void Thread::MyMessageHandler(WPARAM wParam, LPARAM lParam)
{
char data[64] = "";
itoa(wParam, data, 10);
strcat(data, " <<< WPARAM\n");
theApp.FileWrite(data);
}
BEGIN_MESSAGE_MAP(Thread, CWinThread)
ON_THREAD_MESSAGE(WM_MYTHREADMESSAGE, MyMessageHandler)
END_MESSAGE_MAP()</pre><br />
<br />
<code>***ThreadsApp.h***<br />
<pre>class ThreadsApp : public CWinApp
{
public:
ThreadsApp();
void FileWrite(char *data);
virtual BOOL InitInstance();
};
class Thread : public CWinThread
{
DECLARE_DYNCREATE(Thread)
public:
Thread();
virtual ~Thread();
virtual BOOL InitInstance();
virtual int ExitInstance();
void MyMessageHandler(WPARAM wParam, LPARAM lParam);
protected:
DECLARE_MESSAGE_MAP()
};
extern ThreadsApp theApp;</pre><br />
<br />
<code>***ThreadsApp.cpp***<br />
<pre>#include "stdafx.h"
#include "ThreadsApp.h"
ThreadsApp::ThreadsApp()
{
}
void ThreadsApp::FileWrite(char *data)
{
FILE *f;
errno_t err;
err = fopen_s(&f, "C:\\debug.txt", "a");
fprintf(f, data);
fflush(f);
fclose(f);
}
ThreadsApp theApp;
BOOL ThreadsApp::InitInstance()
{
FileWrite("Application initialized\n");
Thread* pThread;
pThread = new Thread();
pThread->CreateThread();
pThread->PostThreadMessage(WM_MYTHREADMESSAGE,1,NULL);
pThread->PostThreadMessage(WM_MYTHREADMESSAGE,2,NULL);
pThread->PostThreadMessage(WM_MYTHREADMESSAGE,3,NULL);
FileWrite("Waiting for the end of thread...\n");
WaitForSingleObject(pThread->m_hThread, 5000);
FileWrite("Program terminated...\n");
return TRUE;
}</pre><br />
<br />
So, what i am doing wrong? :^)<br />
I hope somebody will help :rolleyes:<br />
and thank you very much in advance :rose: :)<br />
<br />
<br />
-- modified at 10:15 Tuesday 31st October, 2006
|
|
|
|
|
Hi
What exactly happens when you run this app? Does the thread freeze when you call pThread->CreateThread();?
Tom
|
|
|
|
|
no, everything runs alright but thread doesn't get messages from *.dll as well as CWinApp can't get messages to...
when message is sent from main application to thread like this:
pThread->PostThreadMessage(WM_MYTHREADMESSAGE,3,NULL);
then everything is alright well almost everything but other issue doesn't matter while i am not getting messages from dll...
this is a dll implementation in thread or how to call that
m_entry.nMessage = WM_MYTHREADMESSAGE; // Our message ID
m_entry.hCallWnd = (HWND)Thread::m_hThread;// Send message to this window
i am not sure if this is right parameter to give for dll (HWND)Thread::m_hThread ?
in the original example it gives m_hWnd i think it is CWnd::m_hWnd its window handler, because dll sends a message into "Graphical" window, i don't want that window, i want invisible application, so creating CWnd class dosn't fits for me i think...
-- modified at 12:57 Tuesday 31st October, 2006
|
|
|
|