|
building a simple dialog using the resource builder will take about 3 min. you cant get faster than that
-Prakash
|
|
|
|
|
Hi,
I have an array of values that is unsorted, having values like 12, 18, 15, 25, 22, 27, 21, 30, 19, 2
I want to rank them acording to the follwing rule , Lets they are 10 values in total
Greater value has the number 10, values less then this will have number 9 , so on , and the least value will have number 1.
How can I do it
thanks
Regards.
|
|
|
|
|
Why can't you just sort the array. The values will be ranked to your given criteria:
rank = "array index of value" + 1.
|
|
|
|
|
zahid_ash wrote: I have an array of values that is unsorted, having values like 12, 18, 15, 25, 22, 27, 21, 30, 19, 2
Apply reverse Bubble Sort and check the Element at the Index!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
ThatsAlok wrote: zahid_ash wrote:
> I have an array of values that is unsorted, having values like 12, 18, 15, 25, 22, 27, 21, 30, 19, 2
Apply reverse Bubble Sort and check the Element at the Index!
Attention!
This only works if no values appear twice in the vector!
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
jhwurmbach wrote: This only works if no values appear twice in the vector!
Thanks for correcting me.. But it seems there is no vector here.. the person seems using old C based array and if you see I especially Quoted his number before giving the answer!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
ThatsAlok wrote: But it seems there is no vector here
But it really should
And its just a matter of:
std::vector<int> vec( &array[0], sizeof(array)/sizeof(array[0]));
to copy array into the STL-vector vec .
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
jhwurmbach wrote: But it really should
Yeah you are right
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
What windows message is created when a SD card is inserted or removed from a USB SD Card reader?
I tried creating a CDialog app and using Spy++ to track it, but you must need to register for it because nothing came to the CDialog window.
And since Windows will offer you services when you insert a card, such as opening explorer to the card... it must be there.
I tried using Spy++ on the explorer window for the SD card reader... but it was a mess of information.
OS is XP or 2000
C++ only please, as i am sure .Net has a pretty answer
thanks
|
|
|
|
|
|
If using MFC, u will get notification OnDeviceChange()
|
|
|
|
|
anilFirst wrote: OnDeviceChange()
Sorry to Point you Sir, OnDeviceChange() is mapped function of WM_DEVICECHANGE only!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Tried the following... It catches the CD door as a reply said it would... no dice on the SD card reader.... Somebody alse asked the question today in a different thread. Another, less obvious course of action was given.
I will repost if that works
LRESULT CTestSdcardDlg::WindowProc (UINT uMsg, WPARAM wParam, LPARAM lParam)//HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
int i = 5;
i++;
switch (uMsg)
{
case WM_DEVICECHANGE:
// Initialize the window.
AfxMessageBox(_T("Test catch"));
break;
default:
break;
}
return CDialog::WindowProc(uMsg, wParam, lParam);
}
|
|
|
|
|
This is an update.... using a different poster's thread answer....
I can now get the insertion and removal of the SD card reader.... I still cannot get the card insertion/removal.
Since its frustrating when people do not post full code examples when they are looking help, i will offer this for code for those of you that solely need to detect a USB device insertion/removal, even though it does not do what i need .......
static /*const*/ GUID GUID_DEVINTERFACE_USB_DEVICE =
{ 0xA5DCBF10L, 0x6530, 0x11D2, { 0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED } };
bool CTestSdcardDlg::DoRegNote()
{
DEV_BROADCAST_DEVICEINTERFACE devInter;
ZeroMemory(&devInter, sizeof(devInter));
devInter.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE);
devInter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
devInter.dbcc_classguid = GUID_DEVINTERFACE_USB_DEVICE;
if(RegisterDeviceNotification(g_hWnd, &devInter, DEVICE_NOTIFY_WINDOW_HANDLE) == NULL)
{
int i = GetLastError();
int j = 5;
}
return true;
}
LRESULT CTestSdcardDlg::WindowProc (UINT uMsg, WPARAM wParam, LPARAM lParam)//HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
switch (uMsg)
{
case WM_DEVICECHANGE:
// Initialize the window.
AfxMessageBox(_T("Test catch"));
break;
default:
break;
}
return CDialog::WindowProc(uMsg, wParam, lParam);
}
|
|
|
|
|
Hi,
I can not have a focus on my button without having a message box on my frame.
Ex: when i have a message or pop-up on my code, i can have a focus on my dynamic button. Otherwise, i can not.
Can you help me!
Thank you.
|
|
|
|
|
Can you use SetFocus() to set focus to the button?
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
|
have you made the control of the button. If yes get the window* for that CWnd and use SetFocus()
Wishes.
Anshuman Dandekar
Dare to Dream,
Care to Achieve.............
|
|
|
|
|
For some reason one malloc works but every other time it fails. Is there something in .NET or a setting that I have to change? This is weird, 'head' allocates and I assign to it but 'myList' never gets memory allocated to it. Any ideas? I'm trying to work with C more that's why I'm using malloc.
paul
<br />
<br />
struct myNode<br />
{<br />
int number;<br />
myNode* link;<br />
};<br />
<br />
int main ()<br />
{<br />
myNode* myList = NULL; <br />
myNode* head = NULL;<br />
<br />
myList = (myNode*)malloc(sizeof(struct myNode));<br />
head = (myNode*)malloc(sizeof(struct myNode));<br />
<br />
myList->number = 4;<br />
myList->link = NULL;<br />
<br />
head->number = 1;<br />
head->link = NULL;<br />
<br />
return 0;<br />
}<br />
|
|
|
|
|
hi,
could you please tell how you're verifying your assertions ?
did you debug or use any if (myList != NULL) ?
i cannot see what's wrong in your code. all seem to be correctly done...
one thing anyway : did you check the remaining memory on your computer ??
(even if i doubt it could be that...)
ps: if you're going to cose with C, declare your struct variables like this :
struct myNode* myList = NULL;
struct myNode* head = NULL;
ps2: when you use dynamically allocated variables like this, don't use them directly as you do here, because there always is the risk that the variable is not allocated, and so, the call to -> operator will fail... (which seeems to be exactly the case here) ; round your code with check tests as presented previously...
ps3: don't forget to free the memory you malloc ated...
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]
-- modified at 13:40 Wednesday 8th February, 2006
|
|
|
|
|
You brought up some good points, thanks for the feedback. I didn't have any if statements to test but when it crashed I used a quickwatch on some of the variables. It would create head* but no myList*, I have no idea why. The code is identical for both of them. Maybe I should try GCC just so I can compare the results.
paully
|
|
|
|
|
paully wrote: ...but when it crashed...
Where?
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
Hi you all.
I have a thread intensive windows service written in Visual C++ for a communicacions app.
There is a mother thread which launches child threads each of which opens a new connection to Oracle by means of the ODBC Driver.
The child threads are created and die, buy sometimes a big amount of them can be created at the same time (about 200 threads when a massive alert is sent to the remote client apps) which mean that about 200 connections are opened against the driver and last for some time.
My problem is that when this happens some threads are frozen in the Open function of the CDatabase connection.
I tried to write a bit of code to test it (one loop which launched threads which just opened connections to the database and waited in an infinite loop to keep everything opened) and the problem persisted. But as this time it was a desktop app (not a winservice) an Oracle ODBC Driver Connect dialog showed asking for Service Name, User Name and Password.
I tested the same code against a SQLServer driver and the app had no problem in launching all the threads.
So now comes the question ¿is there a limit in oracle's driver for the number of connections per process?
I am using Oracle's Driver version 10.01.00.31, the database is an Oracle 10gR1, and the service is written in Visual C++ (Visual Studio 2003).
The database is not owned by us, so we cannot modify any parameters.
|
|
|
|
|
The short answer is probably yes. I'd suggest you look over this[^] article for a start. The artice suggests that the size of the connection pool should be configurable at runtime.
Chris Meech
I am Canadian. [heard in a local bar]
When I want privacy, I'll close the bathroom door. [Stan Shannon]
BAD DAY FOR: Friendly competition, as Ford Motor Co. declared the employee parking lot at its truck plant in Dearborn, Mich., off limits to vehicles built by rival companies. Workers have to drive a Ford to work, or park across the street. [CNNMoney.com]
Nice sig! [Tim Deveaux on Matt Newman's sig with a quote from me]
|
|
|
|
|
I'm using the methods in the following url to monitor a samba folder for changed files (the more modern api to do this isn't supported).
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/obtaining_directory_change_notifications.asp
My problem is that when the connection to the remote drive is lost and restored the call always returns WAIT_TIMEOUT even when changes are made.
Is there a work around for this problem?
PS in the unlikely event taht it matters I'm using the signatures on pinvoke.net to call the API from c#, the relevant portion of the code is a direct port from one language to the next.
|
|
|
|
|