|
Is this at all possible? I cannot use MFC or anything like that.
|
|
|
|
|
SetConsoleTextAttribute
Nish
Sonork ID 100.9786 voidmain
|
|
|
|
|
For a CPropertySheet, I can add a page in the constructor by typing AddPage. I can remove a page in the destructor by typing RemovePage. I read a comment from someone that said you can only call AddPage in the constructor. Is it possible to add and remove pages from a CPropertySheet dynamically? Is it possible/okay to add a button called Add Pages where they click on it and pages are added? Any thoughts?
Any response any one can give me will be greatly appreciated.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
Uou can definitely call 'Addpage' and 'RemovePage' at anytime - we have done this in a number of PopertySheet based dialogs (both normal and wizard mode)
-----------------------------
"I leave no turn un-stoned.
" - John Simmons, Nov 6 2001
-----------------------------
|
|
|
|
|
Yes, you can do that. Additionally, you may send the
PSM_RECALCPAGESIZES to the property sheet when you add/remove pages. You'll find more info about the message in MSDN.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hey Guys
I need a way to put a program into the start up procedure so when windows boots up next time it starts this program.
Any Ideas
Cheers
Peter
|
|
|
|
|
If you're running NT/2000/XP, you'll need to make it a service. For Win9x/ME, you could add it to the "Run" key in the registry or place a shortcut to it in the Startup folder.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
The "run" key in the registry works perfectly fine in NT/2000/XP
You can't make a normal application, with a GUI, a service. There's a big difference between services and "normal" applications...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
I thought he wants his app to run when the system boots, not when someone logs in. Apps in the "Run" and "Run Once" keys are run after you login. Services are run before a user logs in.
http://support.microsoft.com/support/kb/articles/Q137/3/67.ASP
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com.
|
|
|
|
|
Put it in HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion/Run, or /RunOnce if you only want it to run once.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run if you want it to run on windows startup
Write it as a device driver and put it in config.sys if you want it to start before windows
Nish
Sonork ID 100.9786 voidmain
|
|
|
|
|
Here is my class declaration:
#ifndef _FSCONFIGOBJECT_H_
#define _FSCONFIGOBJECT_H_
#define FS_CO_OK 100
#define FS_CO_CANTOPENFILE 101
#define BUFSIZE 1028
enum fsType {fsInteger, fsString, fsDouble};
struct set_element
{
char* name;
fsType type;
char* doc;
void* setting;
};
class fsConfigObject
{
protected:
struct fsCOElem
{
set_element seData;
fsCOElem* pNext;
};
fsCOElem* pLast;
public:
fsConfigObject();
virtual ~fsConfigObject();
void Push(set_element Elem);
void Push(char* name, char* doc, enum fsType type, void* value);
const set_element* GetSetting(char* name);
int SetSetting(char* name, void* value);
int LoadConfig(char* filename);
int SaveConfig(char* filename);
};
#endif
Here is my class definition(sorry if it's long):
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include "fsConfigObject.h"
fsConfigObject::fsConfigObject()
{
pLast = NULL;
}
fsConfigObject::~fsConfigObject()
{
}
const set_element* fsConfigObject::GetSetting(char* name)
{
fsCOElem* pCur = pLast;
while(pCur)
{
if (strcmp(pCur->seData.name, name) == 0)
{
return (&pCur->seData);
}
pCur = pCur->pNext;
}
return ((set_element*)NULL);
}
int fsConfigObject::SetSetting(char* name, void* value)
{
fsCOElem* pCur = pLast;
while(pCur)
{
if (strcmp(pCur->seData.name, name) == 0 )
{
switch(pCur->seData.type)
{
case fsInteger:
pCur->seData.setting = (int*)value;
break;
case fsString:
pCur->seData.setting = (char*)value;
break;
case fsDouble:
pCur->seData.setting = (double*)value;
break;
}
break;
}
pCur = pCur->pNext;
}
if (!pCur)
return NULL;
return 1;
}
void fsConfigObject::Push(set_element Elem)
{
fsCOElem newelem;
newelem.pNext = pLast;
newelem.seData = Elem;
pLast = &newelem;
}
void fsConfigObject::Push(char* name, char* doc, enum fsType type, void* value)
{
set_element elem;
elem.name = name;
elem.doc = doc;
elem.type = type;
elem.setting = value;
Push(elem);
}
int fsConfigObject::LoadConfig(char* filename)
{
FILE* pConfigFile;
pConfigFile = fopen(filename,"r");
if (!pConfigFile)
return FS_CO_CANTOPENFILE;
fseek(pConfigFile, 0, SEEK_END);
int filelen = ftell(pConfigFile);
fseek(pConfigFile, 0, SEEK_SET);
char pchLnBuffer[BUFSIZE];
char pchBuffer;
int nLnNum = 0;
int nLnLen = 0;
char pchVarName[BUFSIZE];
char pchValue[BUFSIZE];
int pos = 0;
memset(pchVarName, '\0', sizeof(pchVarName));
memset(pchValue, '\0', sizeof(pchVarName));
while(!feof(pConfigFile))
{
nLnNum++;
while(1)
{
if (!fread(&pchBuffer,1,1,pConfigFile))
{
pchLnBuffer[pos++] = '\0';
break;
}
if (pchBuffer != '\n' && pchBuffer != '\t')
pchLnBuffer[pos++] = pchBuffer;
else
{
pchLnBuffer[pos++] = '\0';
break;
}
pchBuffer = NULL;
}
nLnLen = strlen(pchLnBuffer);
char* pch = strchr(pchLnBuffer, '=');
if (!pch)
{
printf("Syntax Error: Line %d", nLnNum);
continue;
}
strncpy(pchVarName,pchLnBuffer, pch-pchLnBuffer);
int tmp = strlen(pch);
memmove(pch, pch+1, strlen(pch));
strcpy(pchValue, pch);
pos = 0;
}
fclose(pConfigFile);
return FS_CO_OK;
}
here is a sample program that uses the aforementioned class(Note: Some parts excluded):
int main(int argc, char** argv)
{
fsConfigObject fsco;
fsco.Push("TestVar", "Test Var", fsString, "Test Value");
fsco.LoadConfig("conf\\conf.file");
printf("%s\n", fsco.GetSetting("TestVar"));
return 0;
}
Whenever I run the above I recieve a Access Violation when GetSetting is called.
During debug I see that when LoadConfig is called the values set during push are no longer valid. They no longer exist. It only happens when LoadConfig is called. When I call GetSetting without calling LoadConfig it works fine. Please help. I don't understand what's happening . Thanx.
Stephen Caldwell
Blackfission, CEO
http://bf.steffc.yi.org:81
|
|
|
|
|
Well, I do notice a very possible cause of the problem. Your first Push function creates "newelem" on the stack and then sets "pLast" to point to it. When the function returns, "newelem" is no longer valid (since the stack is cleaned) and "pLast" is left pointing to garbage.
The way to fix it is to allocate newelem on the heap, like this:
void fsConfigObject::Push(set_element Elem)
{
fsCOElem* newelem = new fsCOElem;
newelem->pNext = pLast;
newelem->seData = Elem;
pLast = newelem;
}
But then you need to remember to call delete to free this memory. (At times like these I see the value of Java/VB/C#. ) You can do it in the destructor:
fsConfigObject::~fsConfigObject()
{
fsCOElem* pCur = pLast;
while(pCur)
{
fsCOElem* pDelete = pCur;
pCur = pCur->pNext;
delete pDelete;
}
}
Regards,
Alvaro
|
|
|
|
|
I have a combobox which I have put onto a view using the create function. I have also added three strings using the addstring method. My problem is that when I press the down arrow I get just a line where the top of the list box should go and I can't see anything. I could only guess that the height is of the box is set to one. How do I make the drop down box bigger?
Please Help,
Clint
PS. I am using WTL
|
|
|
|
|
I have recently done something very similar with MFC (guess WTL won't differ much on this). The dimensions you pass to CComboBox::Create() determine the height of the dropdown list. After creation you set the height of the unrolled comobo with CComboBox::SetItemHeight() . You might want to confront this snippet of mine with your code and see if there's any relevant mismatch:
m_combobox.Create(
CBS_DROPDOWNLIST|WS_CHILD|WS_VISIBLE|WS_TABSTOP,
CRect(x,y,x+COMBO_WIDTH,y+4*COMBO_HEIGHT),
this,0xFFFF);
m_combobox.SetItemHeight(0,COMBO_HEIGHT);
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I got the combo box to draw with your code (Slight modifications for WTL) but I can't get it populated now. I use the AddString method but nothing is going into the dropdown list.
Any ideas?
Thanks,
Clint
|
|
|
|
|
Any ideas?
No, this is weird. I use CComboBox:AddString() with no problems at all. Only thing I can think of is maybe you're messing around with the CBS_HASSTRINGS flag or some other comobox style that shouldn't be there.
I suggest you post a (distilled) snippet of code so that we can take a look at it.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I tried everything in another app and it worked so I'll just try and figure it out.
Thanks for your help.
BTW: Have you done anything with custom drawn trackbars and comboboxes?
I have successfully created Ownerdrawn buttons but my trackbars and comboboxes
aren't working at all.
Thanks,
Clint
|
|
|
|
|
With 2 ListBoxes in one DialogBox, how can I change the selected rows in one of them to the other?
|
|
|
|
|
Use GetSelItems() to determine what's selected in listbox #1. Then use SetSel() to select those indices in listbox #2. Listbox 2 should have >= the number of items in listbox #1.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I would like to capture when the user hits the return key when an item in the listbox is selected. However, it would seem that CListBox::VKeyToItem() captures most keystrokes, but only provides an irritating "beep" when I hit return.
What I would like to do is to have the enter key register like a LBN_DBLCLK. Even if CListBox::VKeyToItem() did accept the return key, would it even be possible to have it enable items outside of the CListBox derived class I created?
Any help is greatly appreciated. Thanks in advance.
|
|
|
|
|
Does your list box have the style LBS_WANTKEYBOARDINPUT? If so, OnVKeyToItem() should look something like this:
save status of base class CWnd::OnVKeyToItem() call;
get coords of index of item;
post WM_RBUTTONDBLCLK using those coordinates;
return status;
/ravi
"There is always one more bug..."
ravib@cadence.com
http://www.ravib.com
|
|
|
|
|
Yes, I have LBS_WANTKEYBOARDINPUT. But, it does not seem that OnVKeyToItem is called when the enter key is hit. That is where I am having a major problem. Thanks, though.
|
|
|
|
|
I am working on a dialog that needs to recieve mouse events when I am outside it. In the past I had used a timer in order to call SetCapture when the mouse left the Window, but I felt that was a bit ugly, so this time I tried using WindowFromPoint and passing on messages to windows outside or contained by my own if they were not the ones I was wanting to capture. I found I had to write specific code to press my Close button and I cannot move my dialog. My first approach worked much better, but I always feel that a contant timer == a kludge. Should I just shut up and use the way that works fine, or is there a third, better option ( or maybe something I am missing with option two ) ? I am passing on client and non client mouse events and they work for my child windows, but while Spy++ tells me the messages are being passed to my frame/button, they don't work.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
A couple of ideas spring to mind;
1. How about the TrackMouseEvent function, with an article from Paul Dilascia in MSJ here.
2. What about a system-wide hook? Can't seem to find the link for this right now but I'm sure you'll be able to find it in MSDN - it's a bit late and I'm off to bed now .
Additionally, this might be interesting, another MSJ article. So I like MSJ/MSDN Magasine ok ! (or at least parts of it).
--
Andrew.
|
|
|
|