|
Hello Everybody,
what is the difference between using AfxMessageBox(" ");
and MessageBox(" ");. Both of them are used to display message only then why two versions.
Neelesh Jain
|
|
|
|
|
CWnd::MessageBox will call the MessageBox API using the HWND of the CWnd (the m_hWnd member) as parent window. And can only be used from CWnd derived classes.
AfxMessageBox is an MFC global function and internally call CWinApp::DoMessageBox which calls the MessageBox API and uses the main window of the application as the parent window. AfxMessageBox can be called from anywhere in the MFC program. If you dont have a main window it will use NULL as the parent window
I use CWnd::MessageBox cause it lets you set a title, whereas AfxMessageBox will show the app-name string as the title.
Regards
Nish
Extending MFC Applications with the .NET Framework [NW] (coming soon...)
Summer Love and Some more Cricket [NW] (My first novel)
Shog's review of SLASMC [NW]
Come with me if you want to live
|
|
|
|
|
Hi
I'm in the processof converting a VC.net 2002 project to vc.net 2003 and suddenly got and error with this statement
catch (CException &e)
{
TCHAR szMsg[1000];
e.GetErrorMessage(szMsg, 1000);
ShowErrorMessage(szMsg, "CException", MB_OK, _T(""), GetActiveView());
return FALSE;
}
Can anyone tell me what I should change to get this compile with .net 2003 ? (I'ts probably obvious but I've been awake for 28 hours and am getting a bit tired)
/Thomas
|
|
|
|
|
I want to place a bitmap in the centre of the screen.Now it is in left possition of the screen.
|
|
|
|
|
centerX = (screen_width / 2)-(bitmap_width / 2)
I'm drinking triples, seeing double and acting single
|
|
|
|
|
I'm sure this has been asked before, but I need a no-BS assessment from anyone who has used both the BCG and CodeJock libraries as to their perceptions of both.
It appears that both offer about the same set of features so the remaining question is which one a) is more stable, b) fits more seemlessly into VC++ and VS.NET 2003? Perhaps more importantly, which company is more responsive to customers?
|
|
|
|
|
Here's half an answer.
I use BCG for Awasu since they offered a cheaper version for shareware/freeware/etc. developers. Their sales department seemed reasonably responsive. I emailed CodeJock several times and didn't get any response.
I've found BCG ControlBar to be pretty good. It just works. I had tried some other toolkits whose controls were better (i.e. more features) but I had trouble getting the framework as a whole to work so I ditched them.
BCG works pretty well with VS6. They have a little app that takes care of building the library itself. There is also a project wizard so it's easy to create new BCG-based apps. I believe they work with VS.NET but I haven't tried it.
BCG has a bunch of forums where you can go if you have problems. Their support department is not terribly responsive - I got a cheaper shareware licence which may have something to do with it - but I've never had much need to use them which says a lot in itself. A lot of the time, workarounds and fixes are provided by other users anyway.
All in all, I've been very happy with it.
HTH
"Sucks less" isn't progress - Kent Beck [^]
Awasu 1.1.2 [^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Sir,
Can anybody send simple UDP Program for sending and receiving messages using Sockets.
Thanks in Advance,
Ilamparithi.
|
|
|
|
|
Hey! Know about Google?
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
Hi All!
I am developing application like Instant Messenger(Chat application) in VC++ using CSocket class. The problem I found is when I send the data continuosly using for loop(For example 10 packets), only 2 packets are received in client.
It means that the socket is still processing the data. So the next packet can not be transferred untill the previous transction comes to end. If I use sleep function between every data transmission, it is perfect, but it is so slow in network application
Code (Data lossing)
for(int i=0;i<10;i++)
Socket.Send(Data,sizeof(Data));
Code (Working,but slow)
for(int i=0;i<10;i++)
{
Socket.Send(Data,sizeof(Data));
Sleeep(200);
}
Please understand that I do not know size of sending data. becuase in chat application, size of data depends on the text the user typed.
Send() does not return number of bytes sent actually
OnReceive() will not return error value. It recieves only two packets for 10 packets sending
OnReceive() is executed 2 times not 10 times to check the return value ok.
Multithreading conecpt will come only if you want to accept one more client, not receiving data from one client
If you have idea about this topic please send the mail to mailto:itjegan@sify.com
|
|
|
|
|
Jegan Sasi wrote:
OnReceive() will not return error value. It recieves only two packets for 10 packets sending
OnReceive() is executed 2 times not 10 times to check the return value ok.
That maybe caused by the Nagle algorithm. It is not an error. In fact is efficient and all your data is being sent and received. In very simple terms, the Nagle algorithm consolidates several packets of information sent in a short amount of time into just one send. It is completely transparent to your application.
Even if you disable Nagle you have no control over how the data is received on the other end, the other system may be busy to respond to a receive right away when another chunk of data comes, it will consolidate the whole thing and by the time a receive is processed it will receive both chunks as one.
So, the problem here is that you are assuming that each receive is an individual piece of text.
If all you are doing is sending text back and forth, I suggest you buffer your receives until you reach an end of string (let's say a NULL char) and then do whatever with it.
Remember that there is no guarantee that a receive will contain a whole string, so you have to buffer it until you reach your NULL char, probably on a subsequent receive. Then extract your string from your buffer and keep the rest of the buffer which can contain the beginning of another string to be terminated on another receive.
As a matter of fact, your buffer may very well contain 3 complete strings and a portion of a 4th one. So code accordingly.
Hope this helps,
-Luis
|
|
|
|
|
Hey All,
I've written a hotkey app, but I've noticed that there seems to be a bit of a problem handling certain combinations of modifiers. If I stick to Win + some key (or combo of other modifiers), it works almost all the time. If I try ALT + some key (or combo of modifiers), it doesn't seem to work all that often (if ever).
Is there something I have to do to make my app accept ALT and CTRL hotkeys?
Thanx!
|
|
|
|
|
That acommand was the one which rescued me last night but today im entrapped with this .
actually i wanted to access a URL so I used shellExecute() but my final task was to cvall the url not to open that during execution of the programme
Anyon there to help me i have 2 hrs left with me to do so
PLLLEEEEAAASSSEEE
hdsjdhsjdakldhs lkdhaskdjlahsjkdhaskfhaskjfhasdf
|
|
|
|
|
Ive been working on a program that creates a window and adds a ReBar with two bands, each one for a different Toolbar.
Im using the following code:
INT SetNewBand(HWND hwndOwner, HWND hwndRB, HWND hTool, RECT *rRC)
{
RECT rc ;
RECT hToolRC ;
RECT hwndRBrc ;
REBARBANDINFO rbBand ;
BOOL FirstToolbar = FALSE ;
RECT hToolRC_new ;
/* Fill rbBand structure */
rbBand.cbSize = sizeof(REBARBANDINFO) ;
rbBand.fMask = RBBIM_STYLE | RBBIM_CHILD | RBBIM_CHILDSIZE |
RBBIM_SIZE;
rbBand.fStyle = RBBS_CHILDEDGE | RBBS_USECHEVRON |
RBBS_VARIABLEHEIGHT | RBBS_GRIPPERALWAYS |
RBBS_BREAK ;
GetWindowRect(hwndRB, &hwndRBrc) ;
/* This is the first toolbar */
if (hwndRBrc.top == hwndRBrc.bottom)
FirstToolbar = TRUE ;
GetWindowRect((HWND) hTool, &hToolRC) ;
rbBand.hwndChild = hTool ;
rbBand.cxMinChild = 0 ;
rbBand.cyMinChild = hToolRC.bottom - hToolRC.top ;
rbBand.cx = 200 ;
if (!SendMessage(hwndRB, RB_INSERTBAND, (WPARAM) -1, (LPARAM) &rbBand))
{
dbgprint(("RB_INSERTBAND failed.\n")) ;
return -1 ;
}
// If this is the first toolbar, we dont need to
// fix any sizes.
if (FirstToolbar == TRUE)
{
GetWindowRect((HWND) hTool, &hToolRC) ;
// Leave a space between the gripper and the first button
SetWindowPos(hTool, NULL, 10, 0, 0, 0, SWP_NOSIZE);
GetWindowRect(hwndRB, &hwndRBrc) ;
memcpy(rRC, &hwndRBrc, sizeof(RECT)) ;
return 0 ;
}
// The Tool Bar will be at the bottom of the rest of
// the present windows.
GetWindowRect((HWND) hTool, &hToolRC) ;
if (SetWindowPos(hTool, NULL, 0, hwndRBrc.bottom-hwndRBrc.top, 0, 0, SWP_NOSIZE) == 0)
return -1 ;
GetWindowRect((HWND) hTool, &hToolRC) ;
// The rectangle will include the new Tool Bar.
GetWindowRect((HWND) hwndRB, &hwndRBrc) ;
rc.left = hwndRBrc.left ;
rc.right = hwndRBrc.right ;
rc.top = hwndRBrc.top ;
rc.bottom = hwndRBrc.bottom + rbBand.cyMinChild ;
SendMessage(hwndRB, RB_SIZETORECT, 0, (LPARAM) (LPRECT) &rc) ;
GetWindowRect(hwndRB, &hwndRBrc) ;
GetWindowRect(hTool, &hToolRC_new) ;
SetWindowPos(hTool, NULL, 10, hToolRC.top - hToolRC_new.top,
0, 0, SWP_NOSIZE) ;
return 0 ;
}
If the toolbar is the first, then i add it without doing a RB_SIZETORECT because it is not needed. Else i do so.
What i saw when working with this is
1) If i send RB_SIZETORECT, the second toolbar changes it position and returns to the values before the SetWindowPos.
2) If i do a SetWindowPos after resizing the rectangle of the ReBar window for the second toolbar, then i see it in a right position.
My questions are:
1) If i want to add n toolbars, i will have to set the sizes for each window ? Is there any message or function in Windows API that arranges all of them automatically ?
2) When i modify manually (with the grip) the position of a Toolbar, the buttons dissapear. I have to handle the messages for the ReBar and Toolbar to set the positions of the bands/toolbars every time the users changes it ?
3) If i have to implement the chevron, i will have to handle all the chevron MSGS and also do the TrackPopupMenu with all my buttons ?
Thank you very much for reading this message.
Bye,
Fernando.
Fernando Gabrieli
|
|
|
|
|
Ok, so I want to be able to select a section of text and modify its properties. Well, the CFontDialog class only offers BOOLs for most of the options (underscore, bold, italic, etc. are either TRUE or FALSE). That doesn't allow me to have a third value to set the dialog to if, say, two different parts of the selected text had different properties. The idea would be to check all properties, and set the ones that differ to some third value. Then, on '...DoModal() == OnOK;' Check the values again to see whether they'd been changed to either TRUE or FALSE, and change the entire selection to that. If it's still the third value, then do not change the selection and leave each character just as it was for that property.
So, there's the problem: There's no third state which means to keep the differences intact. And since they're BOOLs, I can't even set the underlying value to some third state to compare with the value after the user's done.
My attempts: So, I tried to do a callback function to somehow try and figure out when the user has made a selection in the font dialog, then I can hopefully ONLY use the selected value(s) to modify the text, NOT the other properties that were not specified. This is still annoying, since it wouldn't show the user an acceptable third (greyed out, but still selectable, like in Word) state, but at least the functionality could be accomplished.
Result: Assertion errors on my attempts at the callback function. I can't seem to make them work.
So, help on the callbacks, or suggestions on showing the user this third state would be greatly appreciated. I'm not good enough to make my own font dialog, I don't think.
halblonious
|
|
|
|
|
I have an image routine that uses bi-linear interpolation to smoothly scale a bitmap from one size to another. Works fine...just to see if I could still do it, I decided to code the same algorithm in inline assembler to determine if I could speed it up. (yeah, I'm a geek)
It did speed it up, but not as much as expected...it was only 15-29% faster, depending on bitmap size, in assembler. (determined using GetTickCount)
Now the question. Is this performance gain what I should expect or is it more likely the curse of a slow algorithm? I know it is hard to answer fully without seeing code...but in general.
Does anyone know where I can get super fast image scaler source code? I would sacrifice some quality for speed.
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
Doesn't surprise me. I did the same thing with a similar algorithm several years ago and saw less of a gain. My biggest gain was by using GDI+ instead.
|
|
|
|
|
It is a question that can't be answered. The problem is that you can get a 15-20% speed increase with assembler on either a good or bad algorithm.
Post the algorithm.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Joe gave me the kind of answer I was looking for. I wasn't looking for help to optimize my code...just feedback from people who have done similar things. Thanks for your reply.
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
I would assume that this is a memory-intensive process in that you need to have the 'source' and 'destination' bitmaps present at the same time. My guess is you need to work the algorithm such that you're not thrashing the CPU cache each time you access the bitmaps.
In our application (ink jet printers), where we generate massive bitmaps, we've found proper cache usage to be critical. The performance difference between a cache hit per pixel and a cache hit per scan line can be an order of magnitude or better.
Software Zen: delete this;
|
|
|
|
|
Gary R. Wheeler wrote:
I would assume that this is a memory-intensive process in that you need to have the 'source' and 'destination' bitmaps present at the same time.
yes...it does this pixel by pixel. it finds 4 source pixels for every destination pixel (based on the scale transformation) so it can interpolate four colors (RGBA) to come up with the destination pixel. it interpolates in each direction x, y. this requires that I find adjacent pixels on two rows and two columns that bound the calculated source pixel location.
I suspose that if I did linear interpolation, instead of bi-linear, and just dealt with a row at a time it would be faster...just don't know how it would look.
I don't know if this makes sense...it's not that complicated, just hard to explain. If you have a better approach I would like to see it.
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
It's not so much the fact that you've got the entire bitmaps in memory at one time, it's how you access it. If you can access it in a fashion that avoids cache misses, which force expensive cache flushes and refills, that improves performance. Typically, you want to access memory through consecutive addresses, 'skipping about' as little as possible.
For your example, let's assume that each pixel in a row occupies consecutive memory addresses. In that case, you want to work within a row as much as possible, and change rows only when you have to. If you went column by column instead, you would have cache misses on almost every pixel reference, which would hamper performance.
(brief pause while I Google bilinear interpolation)
Assuming I understand what bilinear interpolation does, if you keep pointers to a preceding row, current row, and a next row, and increment them down the row, this avoids the cache misses that would occur if you went column by column.
I'm not sure if this helps. Good luck.
Software Zen: delete this;
|
|
|
|
|
I need to traverse the tree with the output function and send its data or the tree over to the List class to be inserted into a List. I am having problems implementing the arguments to be passed in the functions treeNode::Output and List::insertNode. Can somebody give me some ideas. Thanks.
Here is my code:
#include <iostream>
#include <string>
#include "List.h"
using namespace std;
class treeNode
{
string name;
treeNode *smaller, *bigger;
public:
treeNode(string newName="", treeNode *newSmaller=NULL, treeNode *newBigger=NULL)
{
name=newName;
smaller=newSmaller;
bigger=newBigger;
}
void add(string newName)
{
if(newName<name)
{
if(smaller==NULL)
smaller=new treeNode(newName);
else
smaller->add(newName);
}
if(newName>name)
{
if(bigger==NULL)
bigger=new treeNode(newName);
else
bigger->add(newName);
}
}
void output(List &l)
{
if(smaller!=NULL)
smaller->output(l);
l.insertNode();
if(bigger!=NULL)
bigger->output(l);
}
};
void main()
{
List l;
treeNode t;
string newName;
int howMany;
cin >> howMany;
for(int i=0; i<howMany; ++i)
{
cin >> newName;
t.add(newName);
//l.insertNode(treeNode *t);
}
t.output(l);
//l.outputList(cout);
}
#include <iostream>
#include <string>
#ifndef LIST_H
#define LIST_H
using namespace std;
struct node
{
string data;
node *next;
};
//Linked List class
class List
{
node *first;
public:
List()
{
first=NULL;
}
void insertNode()
{
node *p;
cout << newName << endl;
p=new node;
p->data=newName;
p->next=first;
first=p;
}
void outputList(ostream &out)
{
node *p;
p=first;
if(!empty())
{
while(p!=NULL)
{
cout << p->data << endl;
p=p->next;
}
}
else
cout << "The list is empty!" << endl;
}
bool empty()
{
if(first==NULL)
return true;
else
return false;
}
};
#endif
|
|
|
|
|
|
i think i fixed it. Sorry, I never come here and didn't know about those <pre> tags and stuff.
|
|
|
|
|