|
Sorry
CPoint point;
GetCursorPos(&point);
this->ScreenToClient(&point);
CRect rect;
rect.top = point.y;
rect.left = point.x;
rect.right = rect.left + 200;
rect.bottom = rect.top + 300;
CComboBox* pComboBox = new CComboBox();
pComboBox->Create(WS_VISIBLE, rect, this, NULL);
pComboBox->ShowWindow(SW_SHOW);
CDeviceInfoArray arrDeviceInfo;
...
for(int i = 0; i < arrDeviceInfo.GetCount(); ++i)
{
CString strDevice;
strDevice.Format("%d", arrDeviceInfo[i]);
pComboBox->AddString(strDevice);
}
|
|
|
|
|
Is your CTreeCtrl being disguised as a CComboBox ?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Firstly, I use the CTreeCtrl, but failed, then I use the CComboBox, but also failed, too.
I thought that it's the same problem.
|
|
|
|
|
I don't know what this has to do with a tree control, but your Create() call is missing some windows styles (specifically WS_CHILD ), and your control does not have an id. See the documentation[^] for more details.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
At least show us the code you use to create the Tree Control
|
|
|
|
|
please show your CTreeListCtrl creation code. without seeing code how we can predict issue?
|
|
|
|
|
Hi All.
I need to your help in blow questions..
I have to use internet over GPRS modem in windows xp and windows 7, so i have created a dial-up connection using Rasdial API
But i get some problems.
that is, when i creat Ras entry by RasSetEntryProperties api, the entry come up with the default maximum speed of 115200 (but i must use other baud rate, for example, 7200000) .
I can edit this manually in the modem settings, but dose anyone know the API's i can use to set it in code?
I don't want to modify registry about modem.
I have looked through the MDSN, but RasSetEntryProperties function dosen't do it, and it says, lpbDeviceInfo param is unused in Windows XP.
Are there any other solutions except modify registry before making ras entry?
Sorry for my bad english.
Regards.
|
|
|
|
|
This looked easy but it wasn't
I want to
1/ Test if I have rights to delete a file
2/ lock it
3/ read it
4/ delete it
This is all in one process
Gave up on 1/ but tried to use CreateFile to lock it and found xerces-c was not able to access the file for reading in the same process.
Any pointers (no pun intended). Not .net just C++/Win32
Thanks
Iain
|
|
|
|
|
Iain Wiseman wrote: and found xerces-c was not able to access the file for reading in the same process. You really need to explain that in technical terms, i.e. what code you used and what errors you received. I'm not sure about item 1, but 2,3 and 4 are quite straightforward in Windows.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I want to disable other processing from locking the file.
When I use CreateFile, this works except it also prevents Xerces from reading the file so the code looks a little like this
m_Handle = CreateFile(
TEXT(inFullyQualifiedPath.c_str()),
GENERIC_ALL,
0,
NULL,
OPEN_EXISTING,
NULL,
NULL);
m_ConfigFileParser = new xercesc::XercesDOMParser;
m_ConfigFileParser->parse(m_Filename.c_str());
The reading of the file fails because Xerces cannot open the file.
|
|
|
|
|
Solved by using
GENERIC_READ and FILE_SHARE_READ | FILE_SHARE_WRITE
|
|
|
|
|
Iain Wiseman wrote: FILE_SHARE_READ | FILE_SHARE_WRITE You do understand that those options allow other processes to read and write the file at the same time.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
If this isn't correct then is there something that is?
It seemed to work when I ran a separate process with the same code and put a pause in it.
I totally sure you are right. If you do know the right combination I would be grateful. It seemed such a simple thing to want to do.
Iain
|
|
|
|
|
Sorry, I'm not sure exactly what your problem is. You said it works now, I was just pointing out that those options mean you do not have exclusive access to the file.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I am simply after in one process being able to prevent someone else opening a file whilst I am reading it. I do not have control over the opening of the file as this is done within the Xerces library. The file is an xml file hence the use of xerces. Once I have completed the read I want to sometimes delete the file.
Ideally I would have like to in my process
Check I have exclusive rights to the file
Read it using xerces
Delete it
|
|
|
|
|
A Simple work around to your problem would be use your original code to get the exclusive access to file,
Read the file and create a temporary file which you can pass it to Xerces.. later delete the temp file.. and if you want delete even the source/original file.
Other alternatives could be to check if xerces takes text(some temp buffer) as input instead of file name.. so you can read the file in buffer and pass it to xerces.
|
|
|
|
|
Iain Wiseman wrote: I do not have control over the opening of the file as this is done within the Xerces library. In that case there is nothing you can do to gain exclusive access to it. I have no experience of the Xerces library, but are you sure there is no option to pass the handle of a previously opened file into it?
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I did in the end copy the file to a temporary file which gets destroyed on destruction.
Thanks all for your help.
|
|
|
|
|
|
I don't think this should be addressed to me.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Don't you read the file if the access is denied to delete it?
Otherwise, simply try to delete the file using DeleteFile. It will give you ERROR_ACCESSDENIED return code if it fails.
Alternatively you can check the File Security information Check Here[^]
-Sarath.
Rate the answers and close your posts if it's answered
|
|
|
|
|
I AM A LITTLE BIT EXPERIENCED WITH C PROGRAMMING AND PICS BUT AM WONDERING IF ANYONE OUT THERE CAN HELP WITH THE CODE TO RUN A PIC16F8777A OR AN ARDUINO WITH TWO IR SENSORS S1 AND S2 TO PERFORM BIDIRECTIONAL COUNTING IN AND OUT. IN THE FIRST SEQUENCE BREAKING FIRST S1 AND THEN S2 WILL TELL THE MICROCONTROLLER TO INCREMENT THE COUNTER WHILE BREAKING THE SECOND SEQUENCE, FIRST S2 AND THEN S1 WOULD TELL THE MICROCONTROLLER TO DECREMENT THE COUNTER.THE MICROONTROLLER SHOULD ALSO STORE AND TIMESTAMP THE COUNTS AND BE ABLE TO PASS THE TIMESTAMPED DATA TO A REMOTE COMPUTER VIA BLUETOOTH OR WIFI.
ANY HELP WILL BE GREATLY APPRECIATED.
THANK YOU.
|
|
|
|
|
Are the sensors tied to a GPIO line or do you have to talk to them using IIC or SPI? Need a little more info about the sensors before I could offer more assistance. I'm familiar with ARM (mostly Freescale and Atmel stuff) and I'd say that the sensors that I work with are generally tied to a GPIO pin. In that case you just need to read the GPIO pin status or tie it to an interrupt and read them in your app. The logic handling should be simple enough, if S1 is tripped before S2 then increment your counter and log the event to whatever permanent storage you are using, and decrement if you see the sensors in the opposite order. Not having much experience with PIC parts I don't know the exact registers you would need to check for the GPIO status though.
|
|
|
|
|
I am tieing a pair of infrared sensors S1 and S2 onto GPIO lines(digital I/O) of any microcontroller that is easy to program in C as I am new to this.I am looking into ARDUINO UNO(ATmega328 MCU),ARDUINO MEGA(ATmega1280) or a PIC16F877A.I will use the Microcontroller to read the interrupts from the sensors as they change on being broken in the sequence mentioned before.
My main problem is the real coding in C of the logic onto my app.
Can you help with the code?? I wish to have the following functionality:
1) Read interrupts from sensors
2)Increment or decrement counter depending on sequence they are broken
3) timestamp the count and enable storing
4) Pass timestapmed data onto a remote host computer via bluetooth or Wifi.
Do you suggest any parcticular Microcontroller for this application?
Thank you very much.
|
|
|
|
|
Try something like the following for your interrupt handlers. Depending on the micro you select, how to install these will be different. I would stay away from PIC parts, I personally don't like them. The Atmega family of MPU should be better to work with in my opinion, although my personal favorite these days is the Freescale Kinetis family of MPU's. You can get demo boards in the form of expandable towers from Freescale.
[EDIT] You may also want to handle rollover for the counter variable if you expect to have counts high enough for this to happen.
#define S1 (1 << 0)
#define S2 (1 << 1)
unsigned char sensorFlags = 0;
int counter = 0;
void s1_isr(void)
{
if(sensorFlags & S2)
{
--counter;
sensorFlags &= ~S2;
}
else if(sensorFlags & S1)
{
}
else
{
sensorFlags |= S1;
}
}
void s2_isr(void)
{
if(sensorFlags & S1)
{
++counter;
sensorFlags &= ~S1;
}
else if(sensorFlags & S2)
{
}
else
{
sensorFlags |= S2;
}
}
modified 7-Nov-12 14:05pm.
|
|
|
|