|
I feel uneasy about static global nonconst array, but your reasons sound to be solid. You have new, you have matching delete, seems OK(make sure you call delete for each new).
|
|
|
|
|
Here's an easier way:
static char g_szCMOSInfo[][MAX_CMOS_STRING] =
{
{ "Time - Seconds" },
{ "Alarm - Seconds" },
{ "Time - Minutes" },
{ "Alarm - Minutes" },
{ "Time - Hours" },
{ "Alarm - Hours" },
{ "Date - Day Of The Week" },
{ "Date - Day" },
{ "Date - Month" },
{ "Date - Year" }
};
1. It's allocated at compile time so it's very fast,
2. There are no slow heap allocations, and
3. There's no memory to clean up so no leaks to worry about.
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
Ok, but what if the strings are not known at allocation time?
The code I posted was just thought as an example. I also have to allocate more complex structures, for example 200 DDDEVICEIDENTIFIER2 structs (a DirectX structure).
|
|
|
|
|
Yeah, I just read your reply to AlexO.
Your code looks fine, although the static qualifier does not appear to be needed.
The only thing you may want to consider is that if your string values are always going to be literal strings (ie, "abc", "whatever"), then you don't even need to allocate extra space for them:
char* g_szCMOSInfo[NUM_CMOS_STRINGS];
g_szCMOSInfo[i++] = "Time - Seconds";
g_szCMOSInfo[i++] = "Alarm - Seconds";
Since the compiler has already allocated space for literal strings, all you need to do is point to them.
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
Hi,
I complided my software in DEBUG and RELEASE mode all are OK.
But when I execute my RELEASE version, an error message appears " OUT OF MEMORY".
Anyone can help me for debbugging this error or how can I do for checking my memory when I execute my software.
youssef
|
|
|
|
|
check all of your allocations - make sure you aren't trying to allocate any zero element arrays or arrays with huge numbers of elements. in other words - check that the variables you're using to control the array size (Foo *p = new Foo[arraySize];) has been intialized and has a reasonable value.
-c
I'm not the droid you're looking for.
|
|
|
|
|
Have you tried setting lpstrInitialDir to the new directory in the OPENFILENAME structure?
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
I allways inicialize lpstrInitialDir with my path in OPENFILENAME structure!
As I said I have the problem only at app start if the path I want to set doesn't exist anymore! (read the first code I use to solve that)
|
|
|
|
|
I am unable to see your original post, it appears to be "lost", could you check your end and re-post if necessary. Therefore I assume the problem is SetCurrentDirectory() returns TRUE but the path it is trying to set does not exist?
If so why not check the path exists or do a GetCurrentDirectory() and see if it matches where you are. Should these suggestions be totaly wrong just ignore them! I seem to remember something like this happening when I last used these functions, but I am not sure.
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
I solve the problem, and it was my mistake, because I tried to change the path once again with wrong path before I first use the file open/save dialog
uandrej
|
|
|
|
|
How can I send a 'Outlook-Format-Template .oft File' from a C-Programm ???
Harry Diel
|
|
|
|
|
The Problem is as follows.
If you use the Mapi32-Api with C++
The Function :
ULONG FAR PASCAL MapiSendMail( LHANDLE lhSession,
ULONG ulUIParam,
lpMapiMessage lpMessage,
FLAGS flFlags,
ULONG ulReserved);
needs to have a buffer-address for the lpMapiMessage-structure.
If you send normal Text it works.
If you open an Outlook-format-file, rubbish is displayed in the Text-Area
of the Outlook-Diaolog-Box.
If you open a *.oft File with the MS-Explorer the right Format-Text will be displayed in the Outlook-Dialog-Box.
Can anybody answer this ??
|
|
|
|
|
There are two listboxes in my app. When you click on an item in listbox 1, a list of possible options appears in LB 2. You can check these and select some. So each item in LB1 has a set of options from LB2. What I want to do is have a menu item. When you click on this menu, I want the dropdown menu to have a list of the items from LB1. When I click on any submenu item (item from LB1), I want a sub-sub menu (the one that pops up to the side) to show up with the options for that item from LB 1.
Is it possible to have this sort of menu get created? So far I've only made menus in the menu editor. Here the main menu item called "List Search Criteria" will be made by me in the editor, but when I click on it, I want the selections of the user to show up. Of course until the user has selected something, this menu item should be unresponsive. SO maybe it can say "nothing selected" or something.....
Any hints and functions that can be used to do this will be greatly appreciated.
Thanks,
Appreciate your help,
ns
|
|
|
|
|
Look up the menu APIs, they're quite easy. CreatePopupMenu, InsertMenu, AppendMenu, etc.
--Mike--
I'm bored... Episode I bored.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Hello,
INTRODUCTION:
1. I'm trying to install a system wide keyboard hook in order to avoid some keystrokes.
2. I've implemented that static callback f(x) inside a DLL.
3. I call the DLL exported function from a service.
4. I'm sure that the service works right. (it's a SERVICE_WIN32_OWN_PROCESS service).
5. It seems that the callback function that has the hook it's called only one time!.
PROTOTYPE:
static LRESULT CALLBACK HookTeclatLL(int nCode,WPARAM wParam,LPARAM lParam);
CALL
hHookTeclat = SetWindowsHookEx(WH_KEYBOARD_LL, HookTeclatLL, hInstDLLSCT, NULL);
return (hHookTeclat != NULL); <code>the return value is not NULL</code>
CODE:
static LRESULT CALLBACK HookTeclatLL(int nCode,WPARAM wParam,LPARAM lParam)
{
if (nCode == HC_ACTION)
{
switch (wParam)
{
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
case WM_KEYUP:
case WM_SYSKEYUP:
{
LPKBDLLHOOKSTRUCT p = (LPKBDLLHOOKSTRUCT)lParam;
bool bDeleteKey = false;
bDeleteKey = ((p->vkCode == VK_RWIN) ||
(p->vkCode == VK_LWIN) ||
(p->vkCode == VK_ESCAPE) ||
(p->vkCode == VK_F1) ||
(p->vkCode == VK_F2) ||
(p->vkCode == VK_F3) ||
(p->vkCode == VK_F4) ||
(p->vkCode == VK_F5) ||
(p->vkCode == VK_F6) ||
(p->vkCode == VK_F7) ||
(p->vkCode == VK_F8) ||
(p->vkCode == VK_F9) ||
(p->vkCode == VK_F10) ||
(p->vkCode == VK_F11) ||
(p->vkCode == VK_F12) ||
(p->vkCode == VK_CANCEL) ||
(p->vkCode == VK_RBUTTON) ||
(p->vkCode == VK_PAUSE) ||
(p->vkCode == VK_SNAPSHOT) ||
(p->vkCode == VK_APPS) ||
(p->vkCode == VK_SCROLL));
if (!bDeleteKey)
{
if ((p->flags & LLKHF_ALTDOWN) != 0)
{
bDeleteKey = (p->vkCode == VK_TAB);
}
if ((p->flags & MOD_WIN) != 0)
{
bDeleteKey = true;
}
}
if (bDeleteKey)
{
logEstat("\nELIMINANT\n"); <code>In order to monitor only</code>
MessageBox(NULL,"ELIMINANT","",MB_SERVICE_NOTIFICATION); <code>In order to monitor only</code>
return 1; <code>this should remove the key pressed...</code>
}
break;
}
}
}
return CallNextHookEx(hHookTeclat, nCode, wParam, lParam);
}
Do you know anything that I'm missing or that I have misunderstood or something?
The problems are:
1. I think that only one time its called that static callback f(x).
2. the keys are not removed.
3. It seems that the messageboxes never appear... even with the MB_SERVICE_NOTIFICATION...
Thank you in advance.
|
|
|
|
|
I have figured it out...
The service must be interactive in order to be able to install a keyboard hook.
|
|
|
|
|
I have a problem when i create a NT Service that is based on a MFC SDI application.
The application uses the CNTService from the sample from Nigel Thompson.
The problem is that i can't get the GUI to work correct and the GUI are not shown when I log on to my computer.
|
|
|
|
|
I'm new to services, but have you set m_dwServiceType to SERVICE_INTERACTIVE_PROCESS?
Hope this helps.
|
|
|
|
|
I allready have this flag set so that dosen't help.
|
|
|
|
|
You must to set the service in Interactive mode.
Best Regards.
Carlos Antollini.
Pi Five[^]Creator
Sonork ID 100.10529 cantollini
|
|
|
|
|
Hi,
How can I "lock" toolbars and controlbars in place in an application, so the user can resize them, but cannot move them around?
Thanks!
"No one goes to hell because of their sin, but because of rejecting God's method of salvation: His Son's life for yours..."
"It does not take a majority to prevail ... but rather an irate, tireless minority, keen on setting brushfires of freedom in the minds of men." --Samuel Adams
|
|
|
|
|
I have to use an application that uses DAO interface
on a machine (WINNT 4.0) where Access is not installed.
What have I to do in order to let this application work ??
I know that DAO350.DLL and/or DAO360.DLL files must be installed
in the machine, but, is required only files presence or they
must be registerd in the system registry ??
How can I install that DLLs ???
Thank a lot !!!!
|
|
|
|
|
NO, you need a list of several libraries, like jet librarys, error librarys, etc.
Check in your last cd of the Visual Studio 6.0, you will can find the Dao SDK,
into it you will can find a simple installer for dao libraries. I don't remember the name of the package y remmber that have a size of 4 or 5 MB...
Best Regards
Carlos Antollini.
Pi Five[^]Creator
Sonork ID 100.10529 cantollini
|
|
|
|
|
Hello,
I have a problem with pointers.
I want to convert a static array to a dynamically created one. With one dimension, this is easy:
unsigned char array[8000];
would be
unsigned char *array = NULL;
...
array = new unsigned char[8000];
...
delete []array; array = NULL;
This is easy. But how do I convert a static array which has
more than one dimension, lets say 2?
unsigned char array[100][100];
would be what?
-Dominik
|
|
|
|
|
depends:
1. //unsigned char array[100][100];
unsigned char** array = new char [100][100];
...
delete []array; array = NULL;
2. //unsigned char array[100][100];
unsigned char** array = new char* [100];
for(int i = 0; i < 100;++i)
array[i] = new char[100];
...
for(int i = 0; i < 100;++i)
delete[] array[i];
delete []array; array = NULL;
|
|
|
|