Dear forum, I am trying to create a basic level of toolbar customization in my program by allowing the user to choose between big and small icons. Here is the code that goes into WM_CREATE:
HANDLE hFile;
hFile = CreateFile ("C:\\settings.ini", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, NULL, NULL);
DWORD Size;
Size = GetFileSize(hFile, NULL);
char *FileText;
FileText = new char[Size+1];
DWORD Readd;
ReadFile (hFile, FileText, Size+1, &Readd, NULL);
CloseHandle(hFile);
SetDlgItemText(hwnd, IDC_CONFIG, FileText);
char *Icons;
int LineOneSize = SendDlgItemMessage(hwnd, IDC_CONFIG, EM_LINELENGTH, 0, 0);
Icons = new char[LineOneSize];
SendDlgItemMessage(hwnd, IDC_CONFIG, EM_GETLINE, 0, *Icons);
if (Icons == "[icon] big")
{
tbb[0].iString=SendMessage(hTool,TB_ADDSTRING,0,(LPARAM)TEXT(" New "));
tbb[1].iString=SendMessage(hTool,TB_ADDSTRING,0,(LPARAM)TEXT(" Open "));
tbb[2].iString=SendMessage(hTool,TB_ADDSTRING,0,(LPARAM)TEXT(" Save "));
tbb[4].iString=SendMessage(hTool,TB_ADDSTRING,0,(LPARAM)TEXT("Print"));
tbb[6].iString=SendMessage(hTool,TB_ADDSTRING,0,(LPARAM)TEXT("Undo"));
tbb[8].iString=SendMessage(hTool,TB_ADDSTRING,0,(LPARAM)TEXT("Cut"));
tbb[9].iString=SendMessage(hTool,TB_ADDSTRING,0,(LPARAM)TEXT("Copy"));
tbb[10].iString=SendMessage(hTool,TB_ADDSTRING,0,(LPARAM)TEXT("Paste"));
}
if (Icons == "[icon] small")
{
I'm not using the traditional means of using a .ini file, but I don't know all the commands for that, so I'm loading it as a text file. Anyway, the problem is that the program returns the error message instead of large or small icons, like it should. I can't blame the computer, since it's probably my fault. I had a similar problem when I tried to create a program with a registration key. It always returned the "invalid key" message. I never fixed it, because it wasn't critical at the time. This however, is going to be an important part of the program. Can anyone tell me what the problem is? By the way, this problem has nothing to do with linker settings or header files. It's in the code somewhere.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry about this code. I just looked at it and I can safely say that it will never work outside the customize toolbar dialog box. Please ignore this code or state any suggestions for getting toolbar customization.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Dear forum, I am trying to create a basic level of toolbar customization in my program by allowing the user to choose between big and small icons. Here is the code that goes into WM_CREATE:
HANDLE hFile;
hFile = CreateFile ("C:\\settings.ini", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, NULL, NULL);
DWORD Size;
Size = GetFileSize(hFile, NULL);
char *FileText;
FileText = new char[Size+1];
DWORD Readd;
ReadFile (hFile, FileText, Size+1, &Readd, NULL);
CloseHandle(hFile);
SetDlgItemText(hwnd, IDC_CONFIG, FileText);
char *Icons;
int LineOneSize = SendDlgItemMessage(hwnd, IDC_CONFIG, EM_LINELENGTH, 0, 0);
Icons = new char[LineOneSize];
SendDlgItemMessage(hwnd, IDC_CONFIG, EM_GETLINE, 0, *Icons);
if (Icons == "[icon] big")
{
tbb[0].iString=SendMessage(hTool,TB_ADDSTRING,0,(LPARAM)TEXT(" New "));
tbb[1].iString=SendMessage(hTool,TB_ADDSTRING,0,(LPARAM)TEXT(" Open "));
tbb[2].iString=SendMessage(hTool,TB_ADDSTRING,0,(LPARAM)TEXT(" Save "));
tbb[4].iString=SendMessage(hTool,TB_ADDSTRING,0,(LPARAM)TEXT("Print"));
tbb[6].iString=SendMessage(hTool,TB_ADDSTRING,0,(LPARAM)TEXT("Undo"));
tbb[8].iString=SendMessage(hTool,TB_ADDSTRING,0,(LPARAM)TEXT("Cut"));
tbb[9].iString=SendMessage(hTool,TB_ADDSTRING,0,(LPARAM)TEXT("Copy"));
tbb[10].iString=SendMessage(hTool,TB_ADDSTRING,0,(LPARAM)TEXT("Paste"));
}
if (Icons == "[icon] small")
{
}
else
{
MessageBox (NULL, "Error" , "Configuation Error", 0);
}
I'm not using the traditional means of using a .ini file, but I don't know all the commands for that, so I'm loading it as a text file. Anyway, the problem is that the program returns the error message instead of large or small icons, like it should. I can't blame the computer, since it's probably my fault. I had a similar problem when I tried to create a program with a registration key. It always returned the "invalid key" message. I never fixed it, because it wasn't critical at the time. This however, is going to be an important part of the program. Can anyone tell me what the problem is? By the way, this problem has nothing to do with linker settings or header files. It's in the code somewhere.
Sorry about this code. I just looked at it and I can safely say that it will never work outside the customize toolbar dialog box. Please ignore this code or state any suggestions for getting toolbar customization.