|
Hello,
Well apparantly all that was needed to find the answer myself was to post the question here .
The error apparantly was not located in that function, it was a few steps up in the call-stack. There was memory being allocated like:
char* aString = new char(A_Certain_Length);
so with parenthesis in stead of square brackets. How nobody found that out earlier is a wonder to me... Anyways, fixing this fixed the problem. I don't know why this caused the Datatype misalignment error though.
Thanks anyway,
Davy
|
|
|
|
|
OUCH!
char* aString = new char(A_Certain_Length);
What is aString after executing that??
|
|
|
|
|
I am developing a NTService program. And I want to know when any user logs into the system. Is there any kind of message sent to the application program when a user logs in.
|
|
|
|
|
Check out ISensLogon::Logon() .
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I have to put some graphical functions to an dialog-based application using MFC/GDI/GDI+.
One of them is to give the user the abbility to write text-comments on a image.
Like you can do in MSPaint (and Photshop, GIMP ... ).
I found thats relatively easy to parse the mouse - and keyboard input and simply write it to screen (using Graphics DrawString - Method), but it seems to be not trivial to enable editing of the written text (blinking cursor when double-clicking on the text ie).
Or setting up a correct-sized (and blinking ) cursor to signalize, that the app is ready to parse keyboard input.
So, does someone got a idea how to implement MSPaint-like text input on CWnd?
Searched for 2 days for demo-projects or smth like that, no success at all.
Thanks in advance and sorry for my ******* english.
|
|
|
|
|
Hope I understood your question
You draw a image on screen and now you want to write on the image and also you need to modify image.
Maybe this way isnt good but its possible.
You draw your image when you want to write a text on image use of a editbox for gets text and transfer your text when it finish to a external image if you need to modify this text again use of editbox for it.
But maybe you ask I need to write this text on image and also location of text is important,not problem when you click mouse on screen create editbox on it location and set external image on this location when you want to close app or close image write these texts to Main Image.
(You need to arrays for save these text or texts and also location of these texts)
|
|
|
|
|
Hi,
In order to get movable and resizable edit control for placing texts on an image, just search CodeProject website for articles explaining "double subclassing".
Regards
|
|
|
|
|
Hi all,
I read a double (2.567656e-010) from file,
then I convert it into CString and finally i
put it in an edit control, but the value is too small
so in the edit control i find 0.000000.
Here you have the code i use, toremove is
the variable linked to the edit control:
double var=0;
std::fstream f_load;
f_load.open("C:\\best_pop.txt",std::ios::in);
f_load>>var;
CString tmp;
tmp.Format("%lf",var);
toremove.SetWindowText(tmp);
What should i do to see 2.567656e-010 in the edit control ?
|
|
|
|
|
Use
tmp.Format("%g", var);
It should work.
|
|
|
|
|
|
And also you can use of wsprintf
|
|
|
|
|
Hi all!
Look.
typedef (WINAPI *TextOutAType)(HDC,int,int,LPCSTR,int);
TextOutAType oldTextOutAaddr=0;
//here is ourself function
BOOL WINAPI MyTextOutA(HDC hdc, int nXStart, int nYStart, LPCSTR string, int cbString)
{
MessageBox(0,string,"aha",0);
return oldTextOutAaddr(hdc,nXStart,nYStart,string,cbString);
}
BOOL HookApiTextOutA(const HMODULE hModule)
{
IMAGE_DOS_HEADER *pdos;
IMAGE_NT_HEADERS *pnt;
IMAGE_DATA_DIRECTORY *pSymbolTable;
IMAGE_IMPORT_DESCRIPTOR *pimport;
pdos=(IMAGE_DOS_HEADER*)hModule;
pnt=(IMAGE_NT_HEADERS*)((DWORD)pdos + pdos->e_lfanew);
pSymbolTable=&pnt->OptionalHeader.DataDirectory[1];
pimport=(IMAGE_IMPORT_DESCRIPTOR*)((DWORD)pdos + pSymbolTable->VirtualAddress);
while(pimport->FirstThunk){
IMAGE_THUNK_DATA *pold,*pnew;
pold = (IMAGE_THUNK_DATA*)((DWORD)pdos + pimport->OriginalFirstThunk);
pnew = (IMAGE_THUNK_DATA*)((DWORD)pdos + pimport->FirstThunk);
while(pold->u1.Function){
if(IMAGE_ORDINAL_FLAG != (pold->u1.Ordinal & IMAGE_ORDINAL_FLAG))
{
IMAGE_IMPORT_BY_NAME *pname;
pname = (IMAGE_IMPORT_BY_NAME*)((DWORD)pdos + *((DWORD*)pold));
PROC *ppfn=(PROC*)(pnew->u1.Function);
if(strcmp("TextOutA",(char*)pname->Name)==0)
{
oldTextOutAaddr=(TextOutAType)(ppfn); //here is system API "TextOutA" address
DWORD addr=(DWORD)MyTextOutA;
DWORD written=0;
DWORD oldProtect=NULL;
VirtualProtect(&pnew->u1.Function,sizeof(DWORD),PAGE_WRITECOPY,&oldProtect);
WriteProcessMemory(GetCurrentProcess(),&pnew->u1.Function, &addr,sizeof(DWORD), &written);
}
}
pold++;
pnew++;
}
pimport++;
}
return TRUE;
}
Now,when we use TextOutA,it's using "MyTextOutA" first in fact.
TO: Mark Salsbery,this isn't a joke.
IcyGaze, hope make friend with you~
|
|
|
|
|
It seems you could solve your problem
|
|
|
|
|
Haha! Cool
So that works for other processes?
Great to know there's no inter-process protection.
Geez no wonder UNIX guys make fun of Windows!
Nice one!
Mark
|
|
|
|
|
I would like to highlight the state of the button when pressed; i.e. show its 'ON' then reset its state when pressed again - 'OFF'. The following code does not quiet do what I require and I have looked at the methods and not found anything that would do.
void CTabOne::OnBnClickedRelayButton()<br />
{<br />
if(m_bRelayState)<br />
{<br />
m_cRelayButton.SetState(FALSE);<br />
m_cRelayButton.SetWindowTextA("OFF");<br />
m_bRelayState = false;<br />
}<br />
else<br />
{<br />
m_cRelayButton.SetState(TRUE);<br />
m_cRelayButton.SetWindowTextA("ON");<br />
m_bRelayState = true;<br />
}<br />
}
Any suggestions please.
Andy.
|
|
|
|
|
you should use either a Radio button or a checkbox button with the pushbutton style.
|
|
|
|
|
you can write this in your void CTabOne::OnBnClickedRelayButton() function
<br />
CString text;<br />
m_cRelayButton.GetWindowText(text);<br />
if(text == "OFF")<br />
{<br />
m_cRelayButton.SetState(TRUE);<br />
m_cRelayButton.SetWindowText(_T("ON"));<br />
} <br />
if(text == "ON")<br />
{<br />
mm_cRelayButton.SetState(FALSE);<br />
m_cRelayButton.SetWindowText(_T("OFF"));<br />
}<br />
i think this should do
hope that it would help
a.hemdan
|
|
|
|
|
If you have a button I sugget use of a checkbox.
|
|
|
|
|
Hi all,
I got this ErrorExit function of the msdn website, that will cause a messagebox to appear with a description of the last error that occured - if any. But the thing is I'm not sure, what the parameter value of LPTSTR lpszFunction must be ??? .
The function:
<code>
void ErrorExit(LPTSTR lpszFunction)
{
TCHAR szBuf[80];
LPVOID lpMsgBuf;
DWORD dw = GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL );
wsprintf(szBuf,
"%s failed with error %d: %s",
lpszFunction, dw, lpMsgBuf);
MessageBox(NULL, szBuf, "Error", MB_ICONHAND);
LocalFree(lpMsgBuf);
ExitProcess(dw);
}
</code>
Thanx in advance
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
By seing the code, it looks like it is the name of the function. So, basically, you call the function and check the return for an error, if there is an error, you call ErrorExit and pass the function name.
|
|
|
|
|
Thanx for the reply .... I thought that would be the case, but had to make sure,
cause I was receiving the same error message the whole time
"The specified module could not be found : error code 126".
May it be that the function (name) can not be found, or why would I receive the same error
messages although I'm using different applications and methods? :confused: ?
-- modified at 4:06 Thursday 12th October, 2006
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
From where is this message ? And, no, it's not a problem that a 'function' cannot be found: if the function didn't exist, you'll get a compilation error (no declaration and no definition) or a linker error (a declaration exist but no definition). If you could explain from where this message is coming and give more details, then we might help you. But here, we don't have any information...
|
|
|
|
|
O.k, I'll try and explain again. So I call the function and send it a value of a function
that exists and is part of the same application. Then I let a error occur so that I can test the function and the output the messagebox will give me. As shown below.
<br />
wsprintf(szBuf,"%s failed with error %d: %s",lpszFunction, dw, lpMsgBuf); <br />
MessageBox(NULL, szBuf, "Error", MB_ICONHAND); <br />
And the output of the messagebox is:
<functionname> specified module could not be found : error code 126
But the error I caused, as mentioned earlier, was something like this:
<br />
bool a = true;<br />
printf("Value of a %s :",a);<br />
Makes sense??
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
First, please don't use the pre tag to format simple text, it screws the look of your message (need to use the scroll bar to read your message). Pre is used to post code that is quite long.
Programm3r wrote: Then I let a error occur so that I can test the function and the output the messagebox will give me
Which error ? How do you provoke this error ? How do you call the function ? Please post some code because it is totally unclear what you are doing.
Programm3r wrote: bool a = true;
printf("Value of a %s :",a);
This won't set any value for the GetLastError function... It's just a bug but this won't change the return of GetLastError. Some functions only will save an error code that can be retrieved by GetLastError and printf is not. If the function save the error, then it is explicitely stated in the documentation.
Here you are simply retrieving your previous error.
|
|
|
|
|
Huh?
Besides the problems Cédric mentioned...
You say this code...
wsprintf(szBuf,"%s failed with error %d: %s",lpszFunction, dw, lpMsgBuf);
MessageBox(NULL, szBuf, "Error", MB_ICONHAND);
...produced this in a message box:
specified module could not be found : error code 126
???
And what happened here:
bool a = true;
printf("Value of a %s :",a);
Isn't printf going to expect "a" to be a pointer to a character string?
That's not good
Mark
|
|
|
|
|