|
|
How do I get an individual control to accept WM_DROPFILES? I derived a class from CListBox and added the WM_DROPFILES handler. The control in the dialog resource has AcceptFiles set to true, and I even set:
BOOL CSourceListBox::PreCreateWindow(CREATESTRUCT& cs)
{
cs.dwExStyle |= WS_EX_ACCEPTFILES;
return CListBox::PreCreateWindow(cs);
}
The icon just shows as if drop isn't allowed. Any ideas?
|
|
|
|
|
Nitron wrote: The icon just shows as if drop isn't allowed.
You have to manage the icon yourself. You can use a CImageList. It has a bunch of members dealing with drawing a drag icon (BeginDrag,DragEnter,DragLeave,EndDrag... etc.) You also use mouse events and maybe capture the mouse during a drag operation.
|
|
|
|
|
led mike wrote: Nitron wrote:
The icon just shows as if drop isn't allowed.
You have to manage the icon yourself. You can use a CImageList. It has a bunch of members dealing with drawing a drag icon (BeginDrag,DragEnter,DragLeave,EndDrag... etc.) You also use mouse events and maybe capture the mouse during a drag operation.
um... ok, i guess I wasn't clear on my issue... In the OnDropFiles fcn, I have a statement like: AfxMessageBox("Got Drop!"); the WM_DROPFILES message is never getting processed...
|
|
|
|
|
Hello,
I'm trying to read from the registry a value from a key, but I don't understand some parameters from the reading function.
here is a piece of code:
<br />
CRegKey key;<br />
key.Open(HKEY_LOCAL_MACHINE,"Software\\MyProject\\key");<br />
key.SetStringValue("TRUE","TRUE");<br />
if (key.QueryStringValue(?,?,?)=="TRUE") MessageBox("TRUE");<br />
I dont understand the parameters within the QueryStringValue( )
Can you please explain for me what this parameters do and what values for instance I can set to the parameters?
Another problem:
Every time I execute the program I'm getting an assertation that m_hKey ! = 0
I tried to remove the ASSERT line:
<br />
ATLASSERT(m_hKey != NULL);<br />
but it still stops at the line of this assert and gives me the assertation although I removed it.
why?
and how can I remove it for real?
Thanking you in advance!
-- modified at 15:45 Thursday 27th July, 2006
|
|
|
|
|
Semion_N wrote: CRegKey key;
key.Open(HKEY_LOCAL_MACHINE,"Software\\MyProject\\key");
What is the return value? Open will fail if HKLM\Software\MyProject\key does not exist. Use CRegKey::Create() instead.
Semion_N wrote: Every time I execute the program I'm getting an assertation that m_hKey ! = 0
key.open() is failing, so CRegKey::m_hKey is zero.
Do not remove the ASSERTS, they are used to tell you when you do something wrong.
Semion_N wrote: key.QueryStringValue(?,?,?)
From MSDN:
Parameters
pszValueName
Pointer to a null-terminated string containing the name of the value to query.
pszValue
Pointer to a buffer that receives the string data.
pnChars
The size, in TCHARs, of the buffer pointed to by pszValue. When the method returns, pnChars contains the size, in TCHARs, of the string retrieved, including a terminating null character.
Return Value
If the method succeeds, ERROR_SUCCESS is returned. If the method fails to read a value, it returns a nonzero error code defined in WINERROR.H. If the data referenced is not of type REG_SZ, ERROR_INVALID_DATA is returned. If the method returns ERROR_MORE_DATA, pnChars equals zero, not the required buffer size in bytes.
CRegKey key;
if (ERROR_SUCCESS == key.Create(HKEY_LOCAL_MACHINE, "Software\\MyProject\\key"))
{
if (ERROR_SUCCESS == key.SetStringValue("TRUE_KEY", "TRUE_VALUE"))
{
char readbuffer[30] = {0};
ULONG buffersize = 30;
if (ERROR_SUCCESS == key.QueryStringValue("TRUE_KEY", readbuffer, &buffersize))
{
if (0 == strcmp(readbuffer, "TRUE_VALUE"))
{
MessageBox("TRUE");
}
}
}
}
|
|
|
|
|
Thank you!!!
and another question:
How can I check if the key exist?
SnaidiS(Semion)
|
|
|
|
|
Semion_N wrote: How can I check if the key exist?
Call Open() the way you did in your original post and check the returned error code. If the key does not exist Open() will fail with the return value of ERROR_FILE_NOT_FOUND.
Sorry it took so long to respond, I am not getting any reply emails from CP
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
pParams->add(amountId, (char *)&changeAmount, sizeof(changeAmount));
the second parameter looks strange...... haven't dealt with those before....
What's the function of that? [ (char *)&changeAmount ]
|
|
|
|
|
reinterpret_cast()
int x = 0
// 4 bytes on 32-bit
char *p = reinterpret_cast<char *="">(&x)
Kuphryn
|
|
|
|
|
im lost....... not to mention imma beginner
|
|
|
|
|
Actualy I knew one gentelman who casted CString* to CDocument* using reinterpret_cast. Great!
|
|
|
|
|
what is type of changeAmount?
|
|
|
|
|
its an integer
void ChangeBallVelocity(int changeAmount)
{
RTI::ParameterHandleValuePairSet* pParams = NULL;
pParams = RTI::ParameterSetFactory::create( 1 );
pParams->add(amountId, (char *)&changeAmount, sizeof(changeAmount));
rtiAmb.sendInteraction(velocityId, *pParams, NULL);
delete pParams;
}
This is very confusing....
What is pParams assigning?
class RTI_EXPORT ParameterSetFactory {
public:
static ParameterHandleValuePairSet* create(ULong count)
throw (
MemoryExhausted,
ValueCountExceeded,
HandleValuePairMaximumExceeded);
};
|
|
|
|
|
What's strange about it? The second parameter to the add() method is expected to be a char* . changeAmount is some other type, hence the cast.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Dave did you see address of what they are taking and what is going to happen later.
But reinterpret_cast solution was the best
|
|
|
|
|
Jay03 wrote: (char *)&changeAmount
This means that changeAmount is a variable. & turns it into a pointer. So, if changeAmount was an int, &changeAmount is an int *. Then whatever sort of pointer it is, it gets cast to a char *. Now, one has to presume this means it wasn't a char* to start with, but that this cast is valid.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
sorry to ask such a silly question but
Christian Graus wrote: So, if changeAmount was an int, &changeAmount is an int *.
So does this mean (char*) & changeAmount equivalent to : (char *) * int ChangeAmount
So this means, changeAmount was a pointer to an integer and is now changed to a pointer to a character?
|
|
|
|
|
No, it means that IF changeAmount was an int, then the & syntax turns it into a pointer, but that would then be an int *. A cast changes the type, in this case, to char *. That's what the & sytnax does, it returns the address of a variable. And a cast changes a variable type.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Christian Graus wrote: & turns it into a pointer
how does & turn into a pointer.........
|
|
|
|
|
even Christian already gave you a valuable answer, here is another way to understand it.
in the expression (char*)&changeAmount , there are 2 operators called :
1. unary & usually called "address of" and used to get the address of changeAmount
2. (char*) is a cast operator, which explicits the cast of an address previously got with 1. into a char*
doing this changes the type of the pointer on the base address of changeAmount, so that it can be access each byte of that variable.
|
|
|
|
|
sorry to bother u but it makes sense to say changeAmount is an integer pointer and we want to cast it to a char pointer. But in our case changeAmount is NOT an integer pointer, its rather has the address of changeAmount (&changeAmount) ..... how can this be changed into a character pointer now.
it makes sense if it was like this:
(char*) int *changeAmount
pls get me running on the right track.. haha thanks
|
|
|
|
|
The function "add" has a second parameter that appears to take bytes as its type (an array of bytes actually). The & operator takes the address of a variable (that is, gives you a pointer to it) and the (char*) casts it to a charater pointer type. What it is doing is passing in the array of bytes for that variable (the size is passed as the third argument) to do something with them directly (e.g. transmit them over the network perhaps?).
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
// hey here goes the program i have made pls help me out to find errors
#include <iostream.h>
//#include <graphics.h>
#include <conio.h>
#include <stdio.h>
#include <process.h>
class sudoku{
int a[9][9][10],count;
public:
sudoku();
void initsudoku();
void redprob(int , int);
void dispsudoku();
void fillele(int , int );
void fillsudoku();
} ;
sudoku::sudoku()
{ int i , j ,k;
count=81;
cout<<"constructor";
for( i=1;i<=9;i++)
for ( j=1;j<=9;j++){
a[i][j][0]=99;
for ( k=1;k<=9;k++)
a[i][j][k]=0;
a[i][j][10]=9;
}
}
void sudoku::redprob(int i, int j )
{
int k,l,temp;
temp=a[i][j][0];
for ( k=1;k<=9;k++)
{
if (( k!=j) && (a[i][k][temp]!=99));
{ a[i][k][temp] = 99;
a[i][k][10]--;
if(a[i][k][10]==1)
fillele(i,k);
}
if (( k!=i)&&(a[k][j][temp]!=99));
{ a[k][j][temp] = 99;
a[k][j][10]--;
if(a[k][j][10]==1)
fillele(k,j);
}
}
cout<<"l"<<temp;
int="" h="i/3,g=j/3;
" for(="" k="0;k<3;k++)
" {="" l="0;l<3;l++){
" if((="" i!="h*3+k)||(j!=g*3" +l))
="" a[h*3="" +k][g*3="" +l][temp]="99;
" if="" (a[h*3="" +l][10]="=1)
" fillele(h*3="" +k,g*3="" +l);
="" }
="" }
="" }
="" void="" sudoku::initsudoku()
="" {
="" i,j,val;
="" char="" ch="y" ;
="" while(ch="='y')
" {
="" cout<<"enter="" the="" element="" ";
="" element\nrow="" no.";
="" cin="">>i;
cout<<"column no.";
cin>>j;
cout<<"enter value";
cin>>val;
if ((i<=9)&&(j<=9)&&(a[i][j][val]==0)&&(count<=0))
{
a[i][j][0]=val;
a[i][j][10]=0;
count--;
redprob(i,j);
}
else if (i>9)
cout<<"wrong row value";
else if (j>9)
cout<<"wrong column value";
else if (count<=0)
cout<<"already 81 elements have been identified";
else cout<<" you can not place this value here";
cout<<"enter any other element ";
cin>>ch;
}
}
void sudoku::fillele(int i, int j )
{ for( int k=1; k<=9;k++)
if( a[i][j][k] == 0){
a[i][j][0] = k;
a[i][j][10]=0;
count--;
redprob(i,j);
}
}
void sudoku::dispsudoku()
{ int i,j;
for( i=1;i<=9;i++)
{
for ( j=1;j<=9;j++){
if(a[j][i][0]>10){
cout<<" ";
}
else {
cout<
|
|
|
|
|
keshava shukla wrote: pls help me out to find errors
It's actually up to you to find the error(s). Narrow the problem down to just a few lines of code, and then you're bound to get lots of help. No one is going to wade through a bunch of code to find something that you should be finding.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|