|
i wrote this code about the Matrix project here is a part of the code to input the matrix or a vector with a dynamic allocation:
double*vector ; int num ;
cout<<"enter the size of the vector"<<\n;
cin>>num;
vector=new double[num];
for(i=0;i{
cout<<"enter the element"<<i+1<<"in the="" vector"<<\n;
cin="">>*(vector+i)
}
this for input the vector but for input the matrix i made it in another function:
double*grade ; double**matrix ; int row ; int col;
cout<<"enter the number of rows then coloumns in the matrix"<<\n;
cin>>row>>col;
double**matrix=new double*[row];
for(int j=0;j{
matrix[j]=new double[col]
for(int k=0; k{
for( int l=0; l{
cout<<"enter the element"<<l+1<<"in the="" row"<<k+1<<\n;
cin="">>*(grade[k]+l)
}}}
iwant to ask of there is any missing in the followin part of the code
so may you answer these previous questions?
& is this pretag right?
|
|
|
|
|
kosamoza wrote:
is this pretag right?
No, the <pre> and </pre> tags need to surround the code. Before posting, click the Preview button.
See here for an example of a multi-dimensional array.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
hiho@ll
i'm working on a browser helper object and i need to change the http header before a website is called
the problem is how can i change the header?
i tried using the BeforeNavigate function but the customizations are not made by IE (for testing i tried to change the URL, but it was ignored)
so i thingk BeforeNavigate is only for control, if you want to request the url or not (return value true or false)
anybody knows a function or way how to change the http header before it get send by IE?
thx@ll
|
|
|
|
|
NOBODY knows an answer?
can't believe!
ok i have another problem now:
the problem is that DISPID_BEFORENAVIGATE2 doesn't work for that! i get only http headers sent to navigate method (which are not the real headers sent to the server (or not all headers!))
www.debugbar.com is a IE toolbar which can grab the http headers! this means it's possible
the problem i have is that i have to change the http header depending on the header which should be sent an the url to which it should be sent
does anybody know a method how to grab a http header?
maybe i have to code something to grab it from the network interface?
thx@ll
|
|
|
|
|
Hi All
I have written an uninstall program to compliment an install program I have produced. However, how do you get around the problem of removing the uninstall program? It won't delete itself when running. How is uninstall usually done?
I do note that my current install program does not inform the Windows Add/Remove Programs utility - which means I can't use that. It does use the registry but what settings are needed to use the Windows Add/Remove utility?
Is there a way of informing Windows of the program so that I can use the Add/Remove functionality?
Many thanks
u6ik
|
|
|
|
|
u6ik wrote:
However, how do you get around the problem of removing the uninstall program? It won't delete itself when running.
One way is with MoveFileEx(..., MOVEFILE_DELAY_UNTIL_REBOOT) . If you need this functionality on Windows 95, you'll need to use the wininit.ini file. See here for more.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Outstanding.
Cheers Dave.
u6ik
|
|
|
|
|
You can use a .cmd file for it... There is a tutorial about that... but I don't remember where I found it... try google.
Don't try it, just do it!
|
|
|
|
|
Hi there,
I have a dialog box (derived from CDialog), which contains an edit control.
I want to handle the esc and enter keys at the message handler of the edit control, but the esc and enter messages are being translated by accelerators and the whole dialog box closes.
How can I make the keys handled by the edit control?
Thanks for advice,
Alex
Don't try it, just do it!
|
|
|
|
|
Alexander M. wrote:
...but the esc and enter messages are being translated by accelerators and the whole dialog box closes.
See here.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
the best way is to derive a class from CEdit and handle WM_CHAR. there you can do whatever you want in response to VK_RETURN, VK_ESCAPE. also make sure that in your dialog you have handlers for OK and Cancel. In those handlers comment the part with the call of the base class:
void CBDlg::OnOK()
{
// TODO: Add extra validation here
//CDialog::OnOK();
}
Now your dialog will not exit when you press enter.
same for OnCancel..
PS: Stay away from PreTranslate... as it's design is not for this kind of use.
|
|
|
|
|
Yeah the dialog does not exit... but the CEdit does not receive a WM_CHAR message... I've already tried this, but without success.
I will check PreTranslateMessage... lets see what is possible...
Don't try it, just do it!
|
|
|
|
|
What you need to do is handle the WM_ONGETDLGCODE message for your edit control class. This message tells the dialog box procedure what keys to process for your control and which to skip.
For example:
UINT CMyEdit:OnGetDlgCode()
{
return( CEdit::OnGetDlgCode() | DLGC_WANTALLKEYS );
}
Then process in OnChar as normal.
|
|
|
|
|
Perfect answer, that was exactly what I wanted to know... thank you very much!!!
Don't try it, just do it!
|
|
|
|
|
Hey everyone, I'm a little stuck with this and this is my fist question on these boards, and any advice anyone could give would be greatly appreciated
So basically, I have these two COM components that share memory using a MapViewOfFile object... like so:
-----------------------------------------------------------------
In the "server" component:
HANDLE hBlockMap;
...
hBlockMap = CreateFileMapping((HANDLE)0xFFFFFFFF, NULL,
PAGE_READWRITE, 0,
sizeof(Block), "SharedBlockMemory");
In the "client" component:
HANDLE hBlockMap;
...
hBlockMap = ::OpenFileMapping(FILE_MAP_WRITE, FALSE, "SharedBlockMemory");
-----------------------------------------------------------------
I also have a simple "Block" object, just to test sharing data, which looks like this:
-----------------------------------------------------------------
class Block
{
public:
void Write(char* msg);
char* Read();
int getSize() { return n_size; }
Block();
~Block();
private:
BYTE* data;
int n_size;
};
and just the Write and Read methods:
void Block::Write(char* msg, int size)
{
data = new BYTE[strlen(msg) + 1];
memcpy(data, (BYTE* )msg, strlen(msg));
n_size = size;
}
char* Block::Read(int size)
{
char* result = new char[n_size + 1];
memcpy(result, (char* )data, n_size);
return result;
}
-----------------------------------------------------------------
So basically, my problem is this:
The Write and Read methods both actually "work", and by that I mean I'm not getting any wierd memory access violations... If I expand the write method to check and make sure its writing, like so,
void Block::Write(char* msg)
{
...
n_size = size;
char* check = new char[strlen(msg) + 1];
memcpy(check, (char* )data, strlen(msg));
check[strlen(msg)] = '\0';
cout << check << endl;
delete[] check;
}
It outputs the correct string. However, no matter what I seem to do, the Read method just outputs garbage... I'm completely mystified, because if I change, in the Block class, the definition of data to
BYTE data[250];
and then change my Write and Read method to deal with that accordingly, I get the correct output in the Read method. But if use BYTE* data, I just get garbage...
Am I just missing something small, maybe some syntactical error? I haven't programmed in C++ as much lately, and I wouldn't put that myself, but I'm fairly sure my code dealing with the pointers and copying memory is correct... Or is it something else, could I be using the MapViewOfFile incorrectly?
And also, here is an example of how I read from it, just to demonstrate that access to the shared memory is synchronized (using a seperate mutex)...
-----------------------------------------------------------------
class CMemoryMgr
{
public:
...
private:
Block* c_Block;
...
};
void __stdcall CMemoryMgr::TPF_PrintMessage()
{
if(::WaitForSingleObject(hBlockMutex, 5000L) == WAIT_OBJECT_0)
{
cout << c_Block->Read(c_Block->getSize());
cout << endl;
::ReleaseMutex(hBlockMutex);
}
}
-----------------------------------------------------------------
Also, the reason I want to dynamically allocate the data array is because I will be developing a customized circular buffer, and I want to be able to allow data of any reasonable size to be enqueued, so thats why I'm trying to stay away from a fixed array size.
Anyway, thank you all for reading my problem!
Like I said, any advice would be greatly appreciated
|
|
|
|
|
Is is safe to assume you did call MapViewOfFile after creating or opening the memory mapped file?
And this is the 'block' of memory you read and write to?
There is a memory mapped file sample here on CodeProject:
CMemMapFile v1.41
Interprocess communication tutorial
|
|
|
|
|
How do I do a DFT of an image using a FFT to speed things up? My code does not work but is :
int X, Y, num;
long int R;
float data[4096], scale;
RGBQUAD rgb;
num = max(pImage->GetWidth(),pImage->GetHeight());
const DWORD RGB_MAX=RGB(255,255,255);
if (!IsPowerOfTwo(num))
{
return;
}
if (dir == 1)
{
scale = num*num;
}
else scale = 1.0;
for (Y=0; Y<num; Y++)
{
for (X=0;X<=2*num-1;X+=2)
{
data[X] = data[X+1] = pImage->GetPixelGray(X/2,Y);
}
if (!fft(data,num,dir))
return;
for (X=0;X<num;X++)
{
pImage->SetPixelColor(X,Y,RGB(abs(data[X*2]),abs(data[X*2]),abs(data[X*2])));
}
}
for (X=0;X<=2*num-1;X+=2)
{
for (Y=0; Y<num; Y++)
{
R=Y*2;
data[R] = data[R+1] = pImage->GetPixelGray(X/2,Y);
}
if (!fft(data,num,dir))
return;
for (Y=0;Y<num;Y++)
{
R=Y*2;
pImage->SetPixelColor(X/2,Y,RGB(abs(data[R]),abs(data[R]),abs(data[R])));
}
}
Nothing is impossible, It's merely a matter of finding an answer to the question of HOW? ... And answering that question is usually the most difficult part of the job!!!
|
|
|
|
|
I am drawing with a CDC object as follows:
CDC example;
example.Rect ......etc and all the drawing takes place on screen
thne i attempt to convert the CDC to an enhanced Metafile:
CMetaFileDC File;
File.CreateEnhanced(&example, "path", NULL, "NAme");
File.CloseEnhanced();
The file is created but it does not contain anything on it. When i create a simple Metafile, it works fine and makes the file and shows all the drawing info. However this enhanced thing only creates an empty file that is 1 pix x 1 pix.
What am i doing wrong?
thank you
|
|
|
|
|
What code did you use to create the image list?
Don't try it, just do it!
|
|
|
|
|
Here is code that I used for create Image list
<br />
imgList.Create(16, 16, ILC_COLORDDB | ILC_MASK, 6, 1);
|
|
|
|
|
I have an SDI application that is supposed to close it self when finished. To do this it sends a
m_pMainFrame->PostMessage(WM_SYSCOMMAND, SC_CLOSE);
The application appears to stop running and it gives no errors or warnings in release or debug mode. However, task manager almost always shows the application is still in memory. Is there a more forceful way to close an app.
P.S. I have also tried combinations of SW_CLOSE and SendMessage().
Thanks
|
|
|
|
|
Hello,
MSDN says that SC_CLOSE will only close the window. What happens if you try PostQuitMessage() ?
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Thank you.
That worked nicely.
|
|
|
|
|
See here.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Generally the method I use is to send the ID_APP_EXIT command to the main window. This will then use the same exit procedure as if the user clicked "Exit" from the File menu.
For example:
AfxGetMainWnd()->SendMessage( WM_COMMAND, ID_APP_EXIT );
|
|
|
|