|
try with anthor bliting functions as Dibdraw or anthor.
faroq from yemen thammar
working in thammar universty and my intersted about network and security
im programmer from 6 years ago and ihave my B.C from this universty
|
|
|
|
|
See my article "Printing tips and tricks from the trenches" in the printing section. It covers this and over topics.
If you vote me down, my score will only get lower
|
|
|
|
|
There are some very useful points in your article.
OK, so I can't use BitBlt, and I should be using a DIB drawing routine. How do I get a DIB for the picture that has already be drawn into the printer's DC?
SelectObject(hDC, (HBITMAP)NULL) returns NULL
and I can't BitBlt it to a memory DC.
|
|
|
|
|
There is a function present in the article DDBToDIB in the article sourec which can be used to convert a DDB to a DIB. You can use this to get the picture in the right format before calling StretchDIBBits
If you vote me down, my score will only get lower
|
|
|
|
|
Yes, but how do you get the DDB for printer DC. i.e what has previously been written to the printer DC.
|
|
|
|
|
I am working on a project using C and C++ on .NET. I am using existing dll's written in C++, while because of real time considerations, some of the new modules must be written in C, rather than C++. C does not recognize the statement "using namespace ...", and consequently, functions in the C++ modules cannot be found when called from the C modules. Is there another way of letting the C modules know where these functions are?
One solution is to compile the C modules with the C++ compiler. If I do this, will the resulting executables run as efficiently (with respect to execution time) as C code compiled in C, or will they run less efficiently, like C++ code compiled in C++?
Thank you so much for your help.
|
|
|
|
|
I would imagine that if you compile C modules in the C++ compiler, you'll only pay for the overhead of the bits of C++ you use ( in this case, namespaces, whose cost must be close to zero ). However, your best bet is probably to do some benchtesting and see what results you get.
Does ' on .NET' mean you're compiling managed C++ ? If so, then that's different, you will incur the cost of the .NET runtime. One idea would be to make a COM dll, so your .NET code can call non-.NET C++ code easily.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I Override The PreCreateWindow Func
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
cs.style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |WS_MAXIMIZEBOX|WS_MAXIMIZE;
return TRUE;
}
And I want The Restore Button To Be Disabled i Removed The WS_MAXIMIZEBOX style but the resulting window covers the task bar and i don't want that.
I just Like the size the window has when using the above settings combinations but don't want the window to be resized by cliking the restore or double clicking on the title bar
Is There any way i can catch this using the WM_WINDOWPOSCHANGING,WM_NCCALCSIZE,WM_WINDOWPOSCHANGED or WM_SIZE
|
|
|
|
|
use following code:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (BaseClass::OnCreate(lpCreateStruct) == -1)
return -1;
// Do something
// Remove positions of menu
CMenu* pTopMenu = GetSystemMenu(FALSE);
if(pTopMenu != NULL)
{
pTopMenu -> RemoveMenu(SC_SIZE, MF_BYCOMMAND); //remove resizeing
pTopMenu -> RemoveMenu(SC_MOVE, MF_BYCOMMAND); //remove Moveing
pTopMenu -> RemoveMenu(SC_MAXIMIZE, MF_BYCOMMAND); //remove Maximizing
}
return 0;
}
|
|
|
|
|
I Already Done That But When Double Cliking On The Title bar The Window Restores.
|
|
|
|
|
(There's probably a thread like this one every day so... sorry!)
I'm working on a project in which I want to rely only on my own code so therefore I have to go through the pains of writing my own String class. I am a C++ programmer at beginner/intermediate level so there might be some very flagrant errors in there. This is what I have so far:
Declaration
Definition
Any suggestions would be appreciated!
|
|
|
|
|
Whilst I haven't looked at your code, I would suggest seriously considering whether it is worth writing your own string class, given that there are a million implementations of it already both in the standard C++ libraries and on the 'net. Strings are funny because they're succeptible to buffer overflow errors all over the place so if you do implement your own string class, this is something you will have to be very careful of. Alternatively, the std::string class from the STl has this all done already.
Just a suggestion...
--
Andrew.
|
|
|
|
|
Hi,
i need to get the imagenumber from a clistctrl on which i added a imagelist.
At the OnDoubleClick event i need to get the imagenumber from the selected item.
Is there any way to retrieve the number?
I want to compare like
if (imagenumber == CONST_BITMAP_FOLDER)
{
Send next command
}
thx!
|
|
|
|
|
See CListCtrl::GetItem() and LVITEM .
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I do this @ doubleclick event:
<br />
LVITEM lvi;<br />
int nimage;<br />
int nitem;<br />
nitem=m_ctlServerList.GetSelectionMark();<br />
m_ctlServerList.GetItem(&lvi);<br />
nimage=lvi.iImage;<br />
The Problem is lvi.iImage returns always 0.
|
|
|
|
|
Couple of comments:- You should intialize
lvi to zero to ensure the code works correctly in release mode.
- You need to do
lvi.mask = LVIF_IMAGE; before calling GetItem() . Hope this helps!
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Yeah it works fine! thx!
I got a new problem. I Fill a list control with stuff which is todo, i call it todolist.
The size of the ctrl displays 3 items without scrolling (item count varies).
I want to scroll to the current proccess item.
I´ve tried alot but didnt get any good result.
Here´s a code snipped:
<br />
m_nTodoItem=nitem;<br />
m_pCtlListTodo->GetItemRect(0,rect,LVIR_ICON);<br />
size.cy=0;<br />
size.cy=nitem * rect.Height();<br />
m_pCtlListTodo->SetScrollPos(SB_VERT,0);<br />
m_pCtlListTodo->Scroll(size);<br />
<br />
m_pCtlListTodo->Scroll(size);<br />
m_pCtlListTodo->SetSelectionMark(nitem);<br />
Sometimes just the bars scroll without the content.
How to scroll dynamicly with considering user actions.
Thx alot for help and sorry for bad english.
|
|
|
|
|
shibble wrote:
I want to scroll to the current proccess item.
Assuming you know the index of the item, you can call CListCtrl::EnsureVisible() .
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Great,great,great!!!!!
3 Hours of testing with those cra** scrollbars, its just one function..
Thx alot!!!!!!!!!
|
|
|
|
|
Hi,
I have never worked on passing arguments to a cpp file. I am trying to pass a file name as an argument to the program and then return an 2Darray of data. becos i want to call this exe from from an external program.
can anyone help me by giving a prototype syntax for accomplishin this task.
thanks in advance,
Suman
|
|
|
|
|
See this[^] article. Your app should probably write its output to a (user specified) file.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Anyway, my teacher wants us to have an array size of 1,000,000(1 million) and have a segment size of 10000. However, if i put my segment size at 300000 or greater, i get an error saying that the program has encountered an error and needs to close. I can do 100000 and 200000 but anything greater and I get that error.
The programs works fine on 100000 and 200000 it sorts the thread correctly in bubble and multithread sort.
EDIT: For some reason i cant put the code in php.
Here is the code:
#include <windows.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
const int ArraySize=300000;
const int SegmentSize=10000;
const int SleepInterval=10;
DWORD WINAPI SortFun(LPVOID);
void InitializeArray(void);
void Merge(void);
int FindMinKeys(int keys[]);
void DisplayArray(int begin, int end);
void SORT(void);
static int RunFlag = ArraySize/SegmentSize;
int Array[ArraySize];
clock_t start, finish;
double duration;
LPSECURITY_ATTRIBUTES lpthreadattributes = NULL;
DWORD stacksize = 0;
DWORD dwcreationflags;
DWORD ThreadId[ArraySize/SegmentSize];
HANDLE TargetThread[ArraySize/SegmentSize];
void main(void)
{
InitializeArray();
start = clock();
// SORT();
finish = clock();
printf("\n Array Size =%d \n Segment Size =%d \nSleep Interval =%d\n",
ArraySize, SegmentSize, SleepInterval);
printf("\n ***** elapsed time for Single_threaded Bubble sort ****");
duration = (double)(finish - start) / CLOCKS_PER_SEC; // elapsed time in clocks/second
printf("\n clock ticks = %10.3lf\n",(double)(finish-start)); // elapsed time, clock ticks
printf("\n seconds = %10.3lf\n", duration );
// char ch=getchar();
// DisplayArray(0,ArraySize-1);
// ch = getchar();
// Create threads to sort every 1000 th segment of the array
int j=0;
start = clock();
for (int i=0; i<ArraySize; i=i+SegmentSize)
{
TargetThread[j] =
CreateThread(
NULL,
0,
SortFun,
&i,
0,
&ThreadId[j]
);
// printf(" j= %d th thread created\n",j);
//char ch = getchar();
// give time to the newly created thread to work
Sleep(SleepInterval);
// create the next thread
j++;
}
// wait for all threads to complete their work
while (RunFlag > 0)
Sleep(SleepInterval);
// Merge the sorted arrays
Merge();
finish = clock();
printf(" The Entire Array Sorted\n");
printf("\n ***** elapsed time for Multi_threaded Bubble sort ****");
printf("\n ***** Segment Size ***** %d\n",SegmentSize);
duration = (double)(finish - start) / CLOCKS_PER_SEC; // elapsed time in clocks/second
printf("\n clock ticks = %10.3lf\n",(double)(finish-start)); // elapsed time, clock ticks
printf("\n seconds = %10.3lf\n", duration );
// ch=getchar();
// DisplayArray (0,ArraySize-1);
// ch = getchar();
}
void InitializeArray(void)
{
for (int i=0; i<ArraySize; i++)
Array[i] = (rand()*171+rand())%1000000U;
}
void SORT(void)
{
int exchange;
int low = 0;
int high = ArraySize;
// printf(" low = %d high = %d\n",low,high);
for (int k = low; k<high-1; k++)
{
exchange = 0;
for (int l = low; l<= low +high-(k+1); l++)
if (Array[l] > Array[l+1])
{
int t = Array[l];
Array[l] = Array[l+1];
Array[l+1] = t;
exchange = 1;
}
if (exchange == 0) break;
}
}
DWORD WINAPI SortFun(LPVOID N)
{
int exchange;
int low = *(int*)N;
int high = low + SegmentSize-1;
// sort that portion of the array
// printf(" low = %d high = %d\n",low,high);
for (int k = low; k<high-1; k++)
{
exchange = 0;
for (int l = low; l<= low +high-(k+1); l++)
if (Array[l] > Array[l+1])
{
int t = Array[l];
Array[l] = Array[l+1];
Array[l+1] = t;
exchange = 1;
}
if (exchange == 0) break;
}
RunFlag--;
// printf(" ****** Array Segment Sorted ******\n");
//DisplayArray(low,low+SegmentSize-1);
// printf(" i= %d th tread ended\n",low/SegmentSize);
// char ch = getchar();
CloseHandle((void *)&TargetThread[low/1000]);
return 0;
}
void Merge(void)
{
int t[ArraySize];
int p[ArraySize/SegmentSize];
int keys[ArraySize/SegmentSize];
// set the pointers to point to the begining of the sorted segments
for (int i=0; i<ArraySize/SegmentSize; i++)
{
p[i] = i*SegmentSize;
keys[i] = Array[p[i]];
}
// Merge the Array portions
int tposition = 0;;
int Done = 0;
int MinPosition;
while (! Done)
{
MinPosition = FindMinKeys(keys);
if (MinPosition != -1)
{
t[tposition] = Array[p[MinPosition]];
tposition++;
p[MinPosition]++;
if (p[MinPosition] % SegmentSize == 0)
{
// reached the end of one segment
keys[MinPosition] = 1000000U;
}
else
keys[MinPosition] = Array[p[MinPosition]];
}
else
Done =1;
}
for (int j=0; j<ArraySize; j++)
Array[j] = t[j];
}
int FindMinKeys(int keys[])
{
int position = 0;
for (int i = 1; i<ArraySize/SegmentSize; i++)
{
if (keys[i] < keys[position])
position = i;
}
if (keys[position] == 1000000U) return -1;
return position;
}
void DisplayArray(int begin, int end)
{
for (int j=begin; j<=end; j++)
{
printf("%6d Array[i] = %6d \n",j,Array[j]);
}
}
|
|
|
|
|
I am writing my first test C++ .Net program. A simple DLL and a program to call it. The DLL opens up a dialog upon request and displays passed parameters. Both the DLL and the Calling programs are Projects in a Solution.
So far, everything works, expect for the DLL opening the model dialog. I suspect I am not copying the correct information over to the caller directory.
In the property pages of the DLL, I specify two copy statements one to copy the .lib to the caller apps “debug” folder and the other to copy the .dll. (I know I should create my own lib folders somewhere and copy all to those, but this is a test)
This allows the caller app to link and load the dll at execution time, but the does not display the dialog. What am I missing? I have tried copying the .ddl’s .res (compiled resource) to the caller apps ‘Debug” folder, but that didn’t work.
Should I be bringing something else over, or do I need to set an alternative runtime path?
Thanks for your help
Phil
|
|
|
|
|
I have just decided to write my first GUI system and I was wondering if any of you might know of some good reading material or tutorials for getting started with writing and event system
thanks
hair today gone tomorrow
|
|
|
|
|
Hello,
I started to learn Visual C++ a week ago. I used to code in BCB before, a bit on ASM & WinAPI.
At the moment, the main problem for me is creating a GUI. After BCB, creating GUI in VC++ programs seems very difficult and not effectively.
So I have a few questions to you.
1) When I use CFrameWnd object as a main form, and place my controls on it - it flashes when I resize the form.
People adviced me to use WS_CLIPSIBLINGS & WS_CLIPCHILDREN styles and it partially helped.
All controls except Static and Tab Control (CTabCtrl) stopped flashing. Static flashes a bit and Tab Control flashes much. It's like I have a very slow computer =) But it's not true of course.
I have created a small example for u. All u need is compile it and try to resize and u will see that Tab Control flashes hard.
Do you know how to fix it?
2) Another question is: How can I handle right mouse click.
For example I have a static control on my form and I want to show a messagebox when a user clicks right mouse button on it. How can I do this?
I hope you help me guys. Thank you very much for spending your time reading this. Please, help me.
|
|
|
|