|
Farraj wrote: if(a[j]>a[j+1])
is obviously wrong. you need to look at the a value "through the index array".
try
if(a[index[j]]>a[index[j+1]])
that is what you have to pay for the fact that you never actually move the a values around; all you do is change the index values.
You have had the test correct a while ago...
|
|
|
|
|
Yep yep yep for some reason i replaces that line by mistake lol
thank u a lot i appreciate ur help
|
|
|
|
|
|
I want to fully draw combobox control by myself, not only the list items. I searched but only found some demos about how to custom draw its subitems. But I really want to draw the edit, arrow button and listbox of the combobox completely. So, is there any example or idea?
Regards
|
|
|
|
|
I'd say, subclass the combo box and all the controls inside it (list, edit...) and handle WM_PAINT, WM_ERASEBKGND and somesuch. Or write your own complete control from scratch.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
You means, just subclass all its three subitems?
but if use its ownerdraw property?
|
|
|
|
|
I don't understand what you mean...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
I meant, how to use WM_MEASUREITEM and WM_DRAWITEM messages handler if i subclass its edit, button and listbox.
|
|
|
|
|
anyone of you have examples of graphs opencv segmentation, thanks
|
|
|
|
|
Separate the different color channels or segment the image into different color blobs?
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
What exactly is the problem? You don't know how to do color segmentation or you don't know to use OpenCV to do color segmentation?
Here[^] is a simple algorithm for color segmentation using HSV color space. For the problem with OpenCV you will have to be more specific.
-Saurabh
|
|
|
|
|
Are you suppose to collect all the colors uses by an image & put them into different segment accordingly?
If so, then open image into binary format & create four matrix of R,G,B & O (offset values) considering each of them as a segment. Put each RGB values into corresponding martix. Thats all I guess.
If your requirment is somthing else, then im
|
|
|
|
|
Hi All,
I am developing one application that create Internet Shortcut and it is working fine. But in some system it fails to save and Send error message "Access Denied". How to resolve this issue??
Thanks in advance.
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
Firstly i think u should debug your application on those machine, isnt it possible?
well check the below point to.
Check whether ID_IPersistFile is defined as 0000010b-0000-0000-C000-000000000046.
Величие не Бога может быть недооценена.
|
|
|
|
|
Hii, Thanks for ur reply...
yae it is possible i will check it but what does it mean if id is 0000010b-0000-0000-C000-000000000046??
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
Hi,
I am trying to use a Dialog as a Control in another Dialog. MFC Documentation vaguely suggests this as something that can be done (you can set the 'Control' Property in the dialog you want to use as source. The help files and examples become 'thin on the ground' when it comes to how to actually do this. Anybody any ideas?
Bram van Kampen
|
|
|
|
|
I do this a lot in one of my older applications. Suppose your two dialogs are IDD_MAIN and IDD_SUB, with corresponding MFC classes CMainDlg and CSubDlg. The resource for the sub dialog should have the following styles set: Border=None, Style=Child, and Control=True. This will let the sub dialog visually blend into the main dialog.
The basic approach is to use the sub as a modeless dialog whose parent is the main dialog. You then need something like this to get it going:
BOOL CMainDlg::OnInitDialog()
{
CSubDlg *sub = new CSubDlg(CSubDlg::IDD,this);
sub->Create(CSubDlg::IDD,this);
sub->MoveWindow(10,10,100,100);
sub->ShowWindow(SW_SHOW);
} Obviously, there are lots of ways this needs to be fancied up. You probably want this sub-dialog positioned relative to other controls. What I usually do is place a static control where I want the sub-dialog to go, and then position the sub-dialog using logic like this:
CSubDlg *sub = new CSubDlg(CSubDlg::IDD,this);
sub->Create(CSubDlg::IDD,this);
CRect sub_rect;
GetDlgItem(IDC_SUB_DIALOG)->GetWindowRect(&sub_rect);
ScreenToClient(&sub_rect);
GetDlgItem(IDC_SUB_DIALOG)->DestroyWindow();
sub->SetDlgCtrlID(IDC_SUB_DIALOG);
sub->MoveWindow(&sub_rect);
This logic does several things: it gets the position of the static control, destroys it, and then places the sub dialog in the same position. As a final refinement, it assigns the control ID to the sub dialog.
Note that, for completeness, you really should save the pointer to the sub dialog instance as a member of the main dialog class, and delete it in that class' PostNcDestroy().
|
|
|
|
|
|
Glad to be of help .
|
|
|
|
|
Hi! I have to do a project for my studies. It is a insertion algorithm.
I'm reading data from file with using vector.
then I'm copying vector to a normal array (the reason is simple: I don't know how to send vector to function, but this is not a main problem).
After copying, I'm sending (with using pointers) array to sorting function.
Everything is good, algorithm is working but! (yep, there is always but...
When I save a lot of data to file, program just after start crashes.
The numbers in file are written in that way:
1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10
So there are 40 numbers in one line. I have 4.000 lines, so after simple math we have 160.000 numbers. The main problem: when I add some new numbers for example 40.000 program crashes
I must have more numbers because the task is to compare few sorting algorithms with minimum 15 minutes of sorting. (160.000 digits is sorting in ~1 minute)
Here's the code. Maybe it is poor written, but I did my best.
#include <QtCore/QCoreApplication>
#include <iostream>
#include <time.h>
#include <iomanip>
#include <string>
#include <fstream>
#include <vector>
using namespace std;
void insertion_sort(int *wsk, unsigned long size);
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
vector <int> array_vector;
ifstream plik ("numbers.txt",ios::in);
unsigned long single_number;
while(plik >> single_number)
{
array_vector.push_back(single_number);
}
int array_nonsorted[array_vector.size()];
for (unsigned long a = 0; a < array_vector.size(); a++)
{
array_nonsorted[a] = array_vector[a];
}
time_t start,end; double long dif;
cout << "START\n";
time(&start);
insertion_sort(array_nonsorted,array_vector.size());
time(&end);
cout << "STOP\n";
dif = difftime(end,start);
cout << "Array sorted in " << setprecision(5) << dif << "sec"; dif = dif/60; cout << " = " << dif << "minutes";
return a.exec();
}
void insertion_sort(int *wsk, unsigned long size)
{
int tab_sorted[size];
for(unsigned long i = 0; i < size; i++)
{
tab_sorted[i] = wsk[i];
}
for (unsigned long a = 1; a < size; a++)
{
if (a == 1)
{
if (tab_sorted[0] > tab_sorted[1])
{
unsigned long temp = tab_sorted[0];
tab_sorted[0] = tab_sorted[1];
tab_sorted[1] = temp;
}
}
else
{
for (unsigned long b = 0; b <= a-1; b++)
{
if (tab_sorted[a] < tab_sorted[b])
{
unsigned long temp = tab_sorted[a];
for (unsigned long c = a; c > b; c--)
{
tab_sorted[c] = tab_sorted[c-1];
}
tab_sorted[b] = temp;
}
}
}
}
}
So why the program crashes? I don't have a clue Something with memory (but I have 3.0GB and OS works normally when program is starting). Please help!
Luk.
|
|
|
|
|
Have you built a debug version and used the debugger to see where it crashes? That's what I'd to as a starting point.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
hmm, I didn't thought about this, because algorithm works fine, but I did it as you said, and just after debugger started error message came out
<br />
Process stoped. Process was stopped because it received signal from operating system.<br />
Name of signal :SIGSEGV<br />
Meaning of singal : Segmentation fault<br />
Now it is coming to be more interesting.....
I can only click <ok>. After click nothing happened. Even debugging is still on, but do nothing.
I read about SIGSEGV on wiki, but how to avoid it?
|
|
|
|
|
Sounds like you have a wild pointer somewhere. Or have managed to corrupt the heap.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
Maybe someone in the future will be searching solution for similar problem so I wrote it here.
So the problem is with stack array. Array is so large that it overflows the stack.
Solution is to use dynamically sized array. It can be vector class. In this example, it is sufficient to send pointer to function and in the sorting function working on vector. That's all.
//
Thanks to helios for helping me out
(from other cplusplus forum)
|
|
|
|
|
vonpik wrote: int array_nonsorted[array_vector.size()];
1.2MB in size, perhaps?
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|