|
Cheers Yaron ... thanks a lot man, it worked first time.
|
|
|
|
|
i have a query: i use a dialog to take in user input for a rect dimensions but i tested it using AfxMessagebox and encounter assertion error, may i know where is the problem? i have a variable m_length of float type.
void Dialog :: OnOK
{
UpdateData(TRUE);
float length=m_length;
AfxMessageBox(length);
}
|
|
|
|
|
Hi,
this could occur due to several problems:
1) look in the DDX method of the class that the m_length is defined there.
if it is not than the UpdataData(TRUE) will not be valid for m_length.
2) use format string for the float variable as follows:
CString szLength;
szLength.Format(_T("%d"),m_length);
AfxMessageBox(length);
hope this helps ya
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
the DDX method shows:
DDX_Text(pDX, IDC_LENGTH, m_length);
does that mean that the UpDateData(TRUE) is unable to take in the float m_length? i need my member variables to be float preferably because i am using it for OpenGL rendering and as i encountered problems putting my variables into OpenGl that why i was testing to check whether my function can take in the float values.... is there a better way?
|
|
|
|
|
ok, i see the problem now...
open the class wizard (CTRL+W) and go to the definition of IDC_LENGTH and delete the m_str_length member. add a new member called m_length which will be not from CString type but from float type. then you should see an entry in the DDX as follows:
DDX_Text(pDX, IDC_LENGTH, m_length);
now the update data will hold the number within the m_length...and all u have to do is convert it to string and display it....
hope this helps ya
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
erm okie thanx but actually i made a typo error in my earlier message, it is really DDX_Text(pDX, IDC_LENGTH, m_length) already.. so that means AfxMessageBox cannot display a float directly? need to convert to String?
|
|
|
|
|
yes, just do it like this:
UpdateData(TRUE);
CString sz;
sz.Format(_T("%f"),m_length);
AfxMessageBox(sz);
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
coda_x wrote:
so that means AfxMessageBox cannot display a float directly?
Correct. Check the docs and the function prototypes.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
You cannot use AfxMessageBox with a float variable. You need a CString with the float variable this way:
<br />
void Dialog :: OnOK<br />
{ <br />
UpdateData(TRUE);<br />
float length=m_length;<br />
CString my_string;<br />
<br />
my_string.Format("%f", length);<br />
<br />
AfxMessageBox(my_string);<br />
<br />
}<br />
That's all, hope it helped.
Rafael Fernández López.
I didn't fail hundred times, I found hundred ways that didn't work.
No fallé cien veces, encontré cien maneras de que no funcionara.
|
|
|
|
|
Hi all,
I have a problem.
I am reading a string from a vector :
CString szLine = m_vec[1];
int iLen = szLine.GetLength();
now i try to convert it to wide char (unicode) :
wchar_t* pwcSymbol = new wchar_t(iLen + 1);
MultiByteToWideChar(CP_ACP,MB_COMPOSITE,szLine,iLen,pwcSymbol,iLen);
then i just perfrom delete to the wchar_t* :
delete pwcSymbol;
i get an exception......
I read in the MSDN that the out buffer length (the 5th parameter in the MultiByteToWideChar) suppose to be more that the length of the multibyte string..... i am not sure what that means???
can any1 help?
thanks in advanced
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
ok i found the way,
instead of dynamically using wchar_t* i can easily use
std::wstring , the class handles the memory buffering itself....
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
Wrong sort of brackets. You need to allocate an array, not a single wchar_t .
wchar_t* pwcSymbol =
new wchar_t<font color="red">[</font> iLen + 1 <font color="red">]</font>;
delete <font color="red">[]</font> pwcSymbol; The parentheses () indicate a call - to a constructor in this case, meaning that your original code will allocate memory for a single wchar_t and initialise it to the value iLen + 1 .
|
|
|
|
|
thanks man,
that helps too
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
Hi
How to know the parameters of an exported function from a dll. like NTDeleteFile exported from NTDLL.dll
Thanks
|
|
|
|
|
you can undecorate parameters of C++ functions using dependency walker but unfortunately it does not work with C functions
|
|
|
|
|
It's quite simple, you just disassemble the function and work it out from the stack.
Seriously, why do you want to use NtDeleteFile rather than the Win32 DeleteFile ? NtDeleteFile knows nothing of current directories and requires a fully specified path, in NT object manager format. In general, it's better to use the Win32 functions.
If you're looking to reuse a DLL for which you don't have documentation, my advice is not to bother. If the function is undocumented, you should consider it to be an implementation detail which could change in future versions of the DLL. Don't use it.
|
|
|
|
|
|
hello,
I am a begginer. i'm experimenting with a shellexec funtion to try and launch various things from my simple dialog based MFC application. Things like web pages, exe's, and files. I plan on just mapping them to a simple button. can anyone explain (in newb terms) how to get this function to work properly?? How to implement it and where exactly im supposed to add this code??
I would really appreciate any help, Thanks
|
|
|
|
|
In the resource editor, add a button to the dialog
Double click on the button. This adds a method to the dialog class
Add code for the handler.
From MSDN:
HINSTANCE ShellExecute(
HWND hwnd,
LPCTSTR lpOperation,
LPCTSTR lpFile,
LPCTSTR lpParameters,
LPCTSTR lpDirectory,
INT nShowCmd
);
hwnd - 0 - don't worry about the parent window, set to NULL
lpOperation - "open" - open something
lpFile - "your.file" - the file or URL you want to open
lpParameters - "" - unless you need to pass in cmd line params
lpDirectory - "" - unless you care what directory the launched app starts in
nShowCmd - SW_SHOWNORMAL - this will be okay most of the time
ShellExecute(0,"open","http://www.codeproject.com","","",SW_SHOWNORMAL);
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
hi, thank you very much for the info! you got me on the right track.. however when i compile i get an error that reads:
error C2373: 'ShellExecuteA' : redefinition; different type modifiers
i dont know if i put all of the code in the right spot, i added it all under the button function:
void CShell2Dlg::OnButton1()
{
HINSTANCE ShellExecute(
HWND hwnd,
LPCTSTR lpOperation,
LPCTSTR lpFile,
LPCTSTR lpParameters,
LPCTSTR lpDirectory,
INT nShowCmd
);
ShellExecute(0,"open","http://www.codeproject.com","","",SW_SHOWNORMAL);
}
--later
|
|
|
|
|
hi, i'm coding on an interactive sound filter system, but i have a little problem concerning FFT...
i've already coded a directsound micrphone capturing system, but i have the problem, that i don't know how to pass the captured data to a FFT algorithm.
does anyone know e.g. an open-source project which shows how to do this?
thx for advice!
Don't try it, just do it!
|
|
|
|
|
perhaps this helps you
#include <math.h>
#define SWAP(a,b) tempr=(a);(a)=(b);(b)=tempr
void fft(double data[], unsigned long nn, int isign)
{
unsigned long n,mmax,m,j,istep,i;
double wtemp,wr,wpr,wpi,wi,theta,tempr,tempi;
n=nn << 1;
j=1;
for (i=1;i<n;i+=2) {
="" if="" (j=""> i) {
SWAP(data[j],data[i]);
SWAP(data[j+1],data[i+1]);
}
m=n >> 1;
while (m >= 2 && j > m) {
j -= m;
m >>= 1;
}
j += m;
}
mmax=2;
while (n > mmax) {
istep=mmax << 1;
theta=isign*(6.28318530717959/mmax);
wtemp=sin(0.5*theta);
wpr = -2.0*wtemp*wtemp;
wpi=sin(theta);
wr=1.0;
wi=0.0;
for (m=1;m
|
|
|
|
|
I am currently working my way through one of these "Teach youself C++" courses, which has evaluations at the end of each section. Normally I ace these without a problem (I work as a C# coder, so most of this stuff isnt rocket science to me (well maybe with the exception of bitwise operators)).
What has me perplexed is this question in the evaluation :
(Two or more choices) Select the valid C++ expressions
A) char Team[11] = "Marketing"
B) double Grade
C) int 30 = a = b
D) Score = 90
E) x = 100
F) a = b = c = 25
G) PI = 3.14159
My answer was that A and C are incorrect, although A is "technically" correct the array is oversized for the value it is initialised with which is a waste or memory and C for obvious reasons.
Now according to the evaluation program B and C are incorrect, again C for obvious reasons, but whey is B wrong???
This is probably something really simple that I have probably missed, but I just cant see it - feel free to call me a moron, as long as you give me the reason why B is wrong.
post.mode = signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
|
|
|
|
|
I don't think b is incorrect.
MaestroProgramador.Com
I didn't fail hundred times, I found hundred ways that didn't work.
No fallé cien veces, encontré cien maneras de que no funcionara.
|
|
|
|
|
B is incorrect because double Grade is a declaration not an expression. This is a fine point of the language and not something I'd expect to show up in a beginner's book.
A is valid syntax, you don't have to initialize the entire array, and any extra elements will be initialized to zero. However, it is not an expression either.
C is not a valid expression because it's not even valid syntax.
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber
"That probably would've sounded more commanding if I wasn't wearing my yummy sushi pajamas."
-- Buffy
|
|
|
|
|