|
Hi All,
I have a problem.
I have written a Hook Dll. I want to pass a handle from my dll to the application which sets the hook.
So I think I have to use Shared data using
#pragma comment(linker, "/SECTION:.A2IDATA,RWS")
#pragma data_seg (".A2IDATA")
HWND hDlgWnd = NULL;
#pragma data_seg()
Thus I have defined shared section in my dll. But how do I use this shared dta in my application. if write directly
HWND hWnd = hDlgWnd // This give me compile time error saying hDlgWnd not defined..
so how do i access this shared hDlgWnd memory..?
I would appreciate your answer in this regard?
--------------
Vaibhav...
|
|
|
|
|
The data segment of the DLL is not 'visible' to the EXE, even though it is SHARED among all the EXE that have the DLL loaded.
There might be other solutions, but this one is fairly easy and safe to do:
Write a function to return the value of hDlgWnd.
Export the function from the DLL.
Call the function from the EXE instead of trying to access the variable directly from within the EXE.
|
|
|
|
|
Thanks for the answere.
--------------
Vaibhav...
|
|
|
|
|
Hi!
I'm trying to write a small program that analyzes the text in a normal text file.
I'm using the C++ ifstream methods.
My question is:
char *buf;
buf = new char;
ifstream file("test.txt");
...
file.getline(buf, 100);
When I do this buf will contain a row of text.
How do I do to know the size of buf??
I've tried sizeof(buf) but I get = 4
Debugging the code I see that buf has more then 4 character...counting them I get to 77.
Any good tips!
Thanks!
|
|
|
|
|
strlen() function gives the length of a C string, when Sizeof returns the size in bytes of the variable passed as its parameter...
when you write
char *buf;
sizeof(buf);
it will always return 4 because on 32-bits architecture, pointers are 32 bits long, ie. 4 bytes...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
char buf[100];
ifstream file("test.txt");
...
file.getline(buf, 100);
you should do this
I love Programming
|
|
|
|
|
|
Hello,
You can retrieve the extraction count. This is the amount of characters read from the last call to an unformatted input function. Look here[^] and here[^] for more information on gcount() and basic_istream respectively.
int nCount = file.gcount();
Hope this helps.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Hachaso wrote:
file.getline(buf, 100);
If you are going to be asking for 100 bytes from the file, the buffer needs to be large enough. As it stands you are only allocating room for 1. Change the allocation to:
buf = new char[100]; Don't forget to delete it when done!
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I am not able to read plain 8-bit text files (like the one created by Notepad) under windows CE, because this OS natively uses 2-byte Unicode characters: it reads one character every two bytes... For example, the text "ciao" may become 2 chinese symbols.
I'm using the MFC, and CFile::Read(), CArchive::ReadString() ... all don't work. How can i tell him to treat text files as 1-byte ASCII files?
Or maybe i can convert the strings to 8-bit AFTER reading them, but this way i couldn't use ReadString; it wouldn't find the ASCII LineFeed while reading.
Thanks
|
|
|
|
|
Make sure _UNICODE (and UNICODE) is not defined when compiling your code. If for some strange reason that does not work, either use wide-characters (UNICODE) or use one of the functions for converting wide-characters to ASCII.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
In windows CE, unicode is normality, it isn't defined...
You mean functions like wcstombs()? This is not the case, they convert for example L"Hello" to "Hello", while i'd have to phisically split every couple of bytes
|
|
|
|
|
How can i create/open a word doc and add data based on a template. Pls hlp.....
|
|
|
|
|
Hi there,
Search the MSDN for
automation MFC Word HOWTO
you'll get a bunch of old but good articles about Word automation
~RaGE();
|
|
|
|
|
hiho@ll
i want to add a static control to a toolbar for a news ticker
this means a static control in a toolbar with changing text
i already thought of a button without an image, but if i don't use an image i have a little rect left of the text where the image should be
the second problem will be, how to change the text randomly? (in both situations, button or static control)
thx@ll
|
|
|
|
|
Hi!
I'm developing an application using MFC.In the application I've some static controls and some created at runtime.
When the application starts,I want to set the focus to the editbox(created at runtime).
I've used SetFocus and SetTabIndex for this but everytime the focus is being set to the first control created statically.
Kindly help me with this.
Thanks
|
|
|
|
|
This is not an MFC problem. If you set the focus to anything other than the default, then your dialaog init function must return FALSE: otherwise the system will set it to the default keyboard focus.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Hi!
I've implemented context sensitive help on right click of the mouse button.
But after few clicks the application gives Assertion in wincore.cpp.
Kindly help me with this.
Thanks.
|
|
|
|
|
|
thanks for the email, but you'll get better responses if you post the code so that everyone can see it. I am trying to help, but I'm no DavidCrow or toxcct.
Here's what topagarwal sent me:
Message box:<br />
Unhandled exception at 0x7c34055c (MFC71UD.DLL) in CAMU485.exe: User breakpoint.
Code :
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
which line is it blowing up at? I don't think you should be making nResponse an INT_PTR variable. try using int and see what happens. If that works and you still need a pointer, how about making an INT_PTR variable that points to the address of nResponse? I'm not sure what you're trying to do here, so we'll probably need more information
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
I have a property page with radio buttons group derived from CFormView and cannot figure out how to set default radio button - either in the "dialog" or at run time.
My variables are CButton and SetCheck(1) asserts in OnCreate.
Thanks for your help
Vaclav
|
|
|
|
|
I think you should do all this in OnInitDialog() in place of OnCreate.
Jitendra.
|
|
|
|
|
Sorry,
my code does not have OnInitDialog as much as it should.
I'll look into that.
Thanks
Vaclav
|
|
|
|
|
1.)
CButton* pRadio = (CButton*)GetDlgItem(ID_OF_RADIO_BUTTON);
radioState = pRadio->SetCheck(1);
2.)
CButton m_RadioButton; //Declare in .h file
int m_bRadio;
//In Constructor
m_bRadio = 1;
//Write in DoDataExchange function
DDX_Control(pDX, ID_OF_RADIO_BUTTON, m_RadioButton);
DDX_Radio(pDX, ID_OF_RADIO_BUTTON, m_bRadio);
http://www.priyank.in/
|
|
|
|
|
Vaclav wrote:
...in OnCreate.
Why not OnInitialUpdate() ?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|