|
Hi Everyone,
How do I declare an Array inside another Array?
For example, I have the following two arrays:
/////////////////////////////////////////////////////////
int UserInputSize1, UserInputSize2;
int *array1;
array1= new int[UserInputSize1];
int *array2;
array2=new int[UserInputSize2];
//the size of the arrays will be determined by the user input during runtime.
///////////////////////////////////////////////////////
How do I declare them so under array1, it’ll contain the other array?
So for example, if the size of array1 is 3 and the size of array2 is 10, then under every element in array1, I’ll be able to store 10 numbers. Then I’ll be able to store a total of 30 numbers with this example.
I would like to do something like this:
Array1[0].Array2[0]=5;
Array1[0].Array2[1]=10;
Array1[0].Array2[3]=11;
…
If anyone knows, Please let me know.
Thanks in advance
Steve
|
|
|
|
|
You first make an array of int* (in effect, an array of arrays) and then allocate one array for each of the int pointers. Thus:
int** bigarray = new int* [UserInputSize1];
for (int i=0; i < UserInputSize1; i++)
bigarray[i] = new int [UserInputSize2];
bigarray[0][0] = 5;
bigarray[0][1] = 10;
bigarray[0][2] = 15;
Then free the memory in reverse order:
for (int i=0; i < UserInputSize1; i++)
delete [] bigarray[i];
delete [] bigarray;
|
|
|
|
|
The following is a complete program. Is it what you are asking for? If so, then there are many good books about the C and C++ languages that would cover such things much better than the volunteers helping with this forum.
#include <iostream>
using namespace std;
int main(int argc, char *argv[], char *envp[]) {
int Array[3][10], i=0, i1, i2;
for (i1=0; i1<3; ++i1)
for (i2=0; i2<10; ++i2)
Array[i1][i2] = i++;
for (i1=0; i1<3; ++i1) {
for (i2=0; i2<10; ++i2)
cout << Array[i1][i2] << ' ';
cout << endl;
}
return 0;
}
|
|
|
|
|
I have a pdf file. I can read the file, but I can't edit it.
Is there any way of printing text on top of the pdf file
without printing the file and then asking the user to put
the paper back into the printer to print the text on top of
it.
Please, any response any one can give me will be greatly
appreciated.
Sincerely,
Erich J. Ruth (an overworked graduate student)
|
|
|
|
|
1) Customize ghostscript, which claims to be able to handle .pdf files.
2) Hook into GDI, before each EndPage call, add some TextOut calls.
|
|
|
|
|
i'm trying to compile pgp from the source and i need to get the win95 ddk to get it working. microsoft offers the win98 ddk, the win2000 ddk, and the winNT ddk, but i still need the win95 ddk. is there any other place i can find it? thanks in advance.
|
|
|
|
|
Is it possible to stretch a bitmap to the size of a CStatic?
I´m currently using a CStatic control with the SS_BITMAP style to display a bitmap but with this style
the control automatically sizes itself to accommodate it.
The bitmap I want to stretch was included in the project as a resource file.
-------------------------------------------
Marcelo Guerra
|
|
|
|
|
(1) Create a CStatic frame NOT bitmap, but invisible.
(2) Get Chris Maunder's CDIBSectionLite class to draw the bitmap.
(3) Find the size of your CStatic, and using CDIBSectionLite::Stretch draw the stretched bitmap.
HTH
Jerry
|
|
|
|
|
Hi Everyone,
I would like to use an array that has a size that is determined by the user
input. But I'm getting this problem of " array must contain constant " from
this array declaration:
int UserInput;
int TheArray[UserInput];
How do I declare the size of the array with user input?? if anyone knows,
Please let me know.
Thanks in Advance!
|
|
|
|
|
1. If it is a maximum possible array size, you can declare array of this size, like this:
#define MAX_USER_INPUT 255
int TheArray[MAX_USER_INPUT];
Do not forget to check UserInput in this case.
if (UserInput > MAX_USER_INPUT)
// show error message
2. Or use new() and delete()
int *TheArray = NULL;
BOOL InitArray(int *&TheArray, int UserInput)
{
if (UserInput <= 0)
return FALSE;
if (TheArray)
delete[] TheArray;
TheArray = new int[UserInput];
return TheArray != NULL;
}
Don't forget to delete[] TheArray.
|
|
|
|
|
int theUserInput;
theUserInput = 10; // or from user input
int *array;
array = new int[theUserInput];
array[0] = 5; // whatever
|
|
|
|
|
I'm looking for a way to bring up the security dialog (as in file + properties) when I create a file or entry in the registry. I want to give the user a possibility to change the permission (who and what kind of access) of a file/registry entry. Is it possible?
Thanks/Regards
Magnus
|
|
|
|
|
I want to build the function which shows me the on NT work stations .Whether user or adminstrator.
I have build the applications which shows me user and server name.
|
|
|
|
|
i write the following code, but i can't remove the help/OK/Cancel button in the Property Sheet, and i also caanot
resize the PSP why ???
#include "menu.h"
BOOL CALLBACK DlgProc_0(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
BOOL CALLBACK DlgProc_1(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam,LPARAM lParam);
void MakeProp(HWND hWnd);
//
// Main
//
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow)
{
HWND hWnd = GetActiveWindow();
MakeProp(hWnd);
return 0;
}
void MakeProp(HWND hWnd)
{
HINSTANCE hInst;
PROPSHEETPAGE psp;
PROPSHEETHEADER psh;
HPROPSHEETPAGE hpsp[2];
hInst = (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE);
psp.dwSize = sizeof(PROPSHEETPAGE);
psp.dwFlags = PSP_DEFAULT;
psp.hInstance = hInst;
psp.pszTemplate = "DLG0";
psp.pfnDlgProc = (DLGPROC)DlgProc_0;
hpsp[0] = CreatePropertySheetPage(&psp);
psp.pszTemplate = "DLG1";
psp.pfnDlgProc = (DLGPROC)DlgProc_1;
hpsp[1] = CreatePropertySheetPage(&psp);
memset(&psh, 0, sizeof(PROPSHEETHEADER));
psh.dwSize = sizeof(PROPSHEETHEADER);
psh.dwFlags = PSH_USEICONID|PSH_NOAPPLYNOW;
psh.hInstance = hInst;
psh.hwndParent = hWnd;
psh.pszIcon = NULL;
//psh.nPages = sizeof (psp) / sizeof (PROPSHEETPAGE);
psh.nPages = 2;
psh.phpage = hpsp;
psh.pszCaption = "Multiplex";
HWND hPropSheet = (HWND)PropertySheet(&psh);
ShowWindow(GetDlgItem(hPropSheet,IDHELP),SW_HIDE);
ShowWindow(GetDlgItem(hPropSheet,IDOK),SW_HIDE);
ShowWindow(GetDlgItem(hPropSheet,IDCANCEL),SW_HIDE);
MoveWindow(hPropSheet,100,100,320,200,TRUE);
return;
}
//
// DLG0
//
BOOL CALLBACK DlgProc_0(HWND hDlg0, UINT Message, WPARAM wParam, LPARAM lParam)
{
switch(Message)
{
case WM_INITDIALOG:
return TRUE;
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDOK:
return TRUE;
case IDCANCEL:
EndDialog(hDlg0,IDCANCEL);
return TRUE;
case IDC_EDIT0:
if (HIWORD(wParam) == EN_CHANGE)
{
PropSheet_Changed(GetParent(hDlg0),hDlg0);
}
}
return TRUE;
break;
case WM_CLOSE:
EndDialog(hDlg0, WM_CLOSE);
return TRUE;
break;
}
return FALSE;
}
//
// DLG1
//
BOOL CALLBACK DlgProc_1(HWND hDlg1, UINT Message, WPARAM wParam, LPARAM lParam)
{
switch(Message)
{
case WM_INITDIALOG:
return TRUE;
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDOK:
return TRUE;
case IDCANCEL:
EndDialog(hDlg1, IDCANCEL);
return TRUE;
case IDC_EDIT1:
if (HIWORD(wParam) == EN_CHANGE)
{
PropSheet_Changed(GetParent(hDlg1), hDlg1);
}
}
return TRUE;
break;
case WM_CLOSE:
EndDialog(hDlg1, WM_CLOSE);
return TRUE;
break;
}
return FALSE;
}
|
|
|
|
|
You are creating a modal property sheet, so PropertySheet() doesn't return until you close the sheet.
Add PSH_MODELESS to the PROPSHEETHEADER::dwFlags member to make the sheet modeless.
|
|
|
|
|
To remove Help and Apply buttons you can use PSH_NOAPPLYNOW and PSH_HASHELP flags for PROPSHEETHEADER.dwFlags.
"If any of the initial property sheet pages enable a Help button, PSH_HASHELP will be set automatically. If none of the initial pages enable a Help button, you must explicitly set PSH_HASHELP if you want to have Help buttons on any pages that might be added later."
The size of Property sheet is set by the size of the property pages. You can't change it.
"When a property sheet is created, it is sized to fit its initial collection of pages. In order to maintain compatibility with previous versions of the Common Controls, property sheets and wizards do not automatically resize themselves when pages are subsequently added or removed. With Common Controls version 5.80 and later, applications should use the PropSheet_RecalcPageSizes macro after adding or removing pages with PropSheet_AddPage, PropSheet_InsertPage, PropSheet_RemovePage, or their equivalent messages. It ensures that the property sheet is properly sized for its current collection of pages. If this macro or the equivalent message is not used, some property sheet pages may be truncated or too large"
|
|
|
|
|
How can I get the returnvalue of the message handler function?
|
|
|
|
|
In the project I am currently working on, I need to be able to terminate a variety of processes from my main application. I am currently using TerminateProcess(..) to handle this task, but I have run across an issue with the command prompt.
If the command prompt is running, and having started no application, then TerminateProcess(..) works fine.
If the command prompt has been used to start another application, such as FTP or edit, the the call to TerminateProcess(..) returns a non-negative value, but the command prompt does not exit until the application it is running has exited.
Does anyone know how to programatically force a command prompt to exit regardless of what application it may be running? Any help is greatly appreciated.
|
|
|
|
|
Hello...
I can't find CCheckLixtBox as a Base class on Class Wizard
Do I have to make the files manually?
Thanks
JC
|
|
|
|
|
There sure is not much information about CCheckListBox. Perhaps you should submit it to Microsoft as a deficiency; if it is, then you could get an answer from them.
|
|
|
|
|
I want to convert a Date&Time string, for example, "08:30:25 Sep-25-00", to a DATE data type without the help of MFC. Could anyone tell me how to do that in COM way or Win32 API way?
Thanks,
Tony
|
|
|
|
|
Hi all,
how can i use the unicode/ansi conversion macros like T2A( ) in an c-file.
The macros are defined in the afxpriv.h, but if i include this headerfile i get
the error that my file has no 'cpp' extension.
-> #error MFC requires C++ compilation (use a .cpp suffix)
Can anybody help with a solution or a workaround?
TIA, Chris
|
|
|
|
|
The "work abound" is to change the extension of your file from .c to .cpp. Then if you want the functions
in your new .cpp to be callable from other .c file functions, wrap your functions like this:
#ifdef __cplusplus
extern "C" {
#endif
int foo();
#ifdef __cplusplus
}
#endif
|
|
|
|
|
Hi,
I made a simple MFC app with webbrowser cotrol..
With this, I opened a local html file with vbscript in it..
The script follows:
' This procedure is a brief sample showing
' how to automate PowerPoint from Outlook.
' Get a reference to the PowerPoint Application object.
Set appPowerPoint = CreateObject("PowerPoint.Application")
' Display the application.
appPowerPoint.Visible = TRUE
' Open a sample presentation.
appPowerPoint.presentations.Open("test.ppt")
MsgBox "At this point PowerPoint is open and displays a document. The following statements will close the document and then close PowerPoint."
' Close the presentation.
appPowerPoint.ActivePresentation.Close
' Quit PowerPoint.
appPowerPoint.Quit
' Close the object variable.
Set appPowerPoint = Nothing
And there occurs an error...
It means on the next line of --Set appPowerPoint = CreateObject("PowerPoint.Application")--
Next line is blank...and the message means like..
-->you missed ")" ( I can't remember exactle what it was..)
What I wonder is..
1. Can I use Office automation like vb in clien vbscript??
2. If #1 possible...plz show me some code...
Thanks for reading..
Any suggestion??
Regardz
-Ryan
|
|
|
|
|
Hi!
I have a problem with colors in my C++ MFC application.
The dialog window looks for what colors windows have in the registry and uses these colors to color the dialog. Thats the system colors that are located in the registry under the key: "MyComputer\HKEY_CURRENT_USER\Control Panel\Colors". These are the so called system colors, the colors the system sets for your dialog (if you don't draw it yourself). What I want to do is, I'd like my dialog window to look for it's own colors in the same kind of way, but at another location, wich I would have define. Maybe,"MyComputer\HKEY_CURRENT_USER\Software\MyProgram\Colors" where I can set the dialog window colors myself. To do this, I have to change where in the registry my dialog window looks for it's colors. Adding the necissary keys and colors is no biggie, but how do I redirect where\how the program looks for these colors?
If you don't know how to do this, could you help me with how the overriding of the OnPaint function should look like for any of the following things: A slider, ComboBox, the menu, the dialog window and boarder.
Thx, most thankfull for help. =)
/Fredrik
|
|
|
|
|