http://www.h-online.com/open/news/item/Qt-implementation-for-Android-introduced-1194815.html
Microsoft All-In-One Code Framework
22 02 2011Check it here:
http://1code.codeplex.com/
Comments : Leave a Comment »
Categories : Programming
VB6 ScaleLeft ScaleTop to VB.NET conversion
20 05 2010Whenever you find .Scale(x) dimensions
TextBox1.ScaleTop TextBox1.ScaleLeft TextBox1.ScaleHeight TextBox1.ScaleWidth
simply change it into .ClientRectangle.(x) form
TextBox1.ClientRectangle.Top TextBox1.ClientRectangle.Left TextBox1.ClientRectangle.Height TextBox1.ClientRectangle.Width
Hope it helps.
Comments : Leave a Comment »
Categories : Programming
VB6 Format(Now) for milliseconds
7 04 2010Option Explicit Private Type SYSTEMTIME '16 Bytes wYear As Integer wMonth As Integer wDayOfWeek As Integer wDay As Integer wHour As Integer wMinute As Integer wSecond As Integer wMilliseconds As Integer End Type Private Declare Sub GetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)
Usage:
Dim NowTime As SYSTEMTIME Dim sYear, sMonth, sDayOfWeek, sDay, sHour, sMinute, sSecond, sMilliseconds As String GetSystemTime NowTime sYear = Format(NowTime.wYear, "0000") sMonth = Format(NowTime.wMonth, "00") sDay = Format(NowTime.wDay, "00") sHour = Format(NowTime.wHour, "00") 'wHour - or + X depends local timezone sMinute = Format(NowTime.wMinute, "00") sSecond = Format(NowTime.wSecond, "00") sMilliseconds = Format(NowTime.wMilliseconds, "000")
Comments : 1 Comment »
Categories : Programming
A simple Modeless AfxMessageBox
10 12 2008There were times when AfxMessageBox freezes my background process thread (socket communication, etc.) Here’s what I wrote as a quick and dirty solution. Put it in your StdAfx.h
You can refine it if you like.
//////////////////////////////////////////////////////////////////////////
// ivo setyadi [12/10/2008 Development]
// a simple (or semi) modeless AfxMessageBox using MFC thread
// usage:
// CMy my;
// my.ModelessBox("your message");
class CMy
{
public:
void ModelessBox( CString str)
{
char *buffer=new char[256];
lstrcpy(buffer,str);
AfxBeginThread(showMessage, (LPVOID *) buffer, THREAD_PRIORITY_NORMAL) ;
}
static UINT showMessage(LPVOID lParam)
{
if(lParam == NULL)
AfxEndThread(NULL);
char *pStr = (char *) lParam;
AfxMessageBox(pStr);
delete pStr; // don't forget
return TRUE;
}
};
There.
Comments : 1 Comment »
Categories : Programming
OnMouseLeave
21 02 2008How to catch an OnMouseLeave event? Using TrackMouseEvent.
Here’s what I did:
in the CNewsBar .h
class CNewsBar : public CToolbar
{
protected:
BOOL m_bTraceMouse;
afx_msg LRESULT OnMouseLeave(WPARAM wParam, LPARAM lParam);
};
in the CNewsBar .cpp
BEGIN_MESSAGE_MAP(CNewsBar , CToolBar)
ON_WM_MOUSEMOVE()
ON_MESSAGE(WM_MOUSELEAVE, OnMouseLeave)
END_MESSAGE_MAP()
CNewsBar ::CNewsBar ()
{
m_bTraceMouse = FALSE;
}
void CNewsBar ::OnMouseMove(UINT nFlags, CPoint point)
{
if (!m_bTraceMouse)
{
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(TRACKMOUSEEVENT);
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = this->m_hWnd;
if (::_TrackMouseEvent(&tme))
{
m_bTraceMouse = TRUE;
}
}
CToolBar::OnMouseMove(nFlags, point);
}
LRESULT CNewsBar ::OnMouseLeave(WPARAM wParam, LPARAM lParam)
{
m_bTraceMouse = FALSE;
return TRUE;
}
Comments : Leave a Comment »
Categories : Programming
C puzzles
26 03 2007Some interesting C problems 🙂
It’s on Gowri Kumar’s page.
Here’s one of the problem:
The following C program segfaults of IA-64, but works fine on IA-32.
int main()
{
int* p;
p = (int*)malloc(sizeof(int));
*p = 10;
return 0;
}
Why does it happen so?
Check out the full article here:
http://www.gowrikumar.com/c/index.html
Comments : 3 Comments »
Categories : Programming
Typedef
28 03 2006Although typedef is thought of as being a storage class, it isn't really. It allows you to introduce synonyms for types which could have been declared some other way. The new name becomes equivalent to the type that you wanted, as this example shows.
typedef int aaa, bbb, ccc; typedef int ar[15], arr[9][6]; typedef char c, *cp, carr[100]; /* now declare some objects */ /* all ints */ aaa int1; bbb int2; ccc int3; ar yyy; /* array of 15 ints */ arr xxx; /* 9*6 array of int */ c ch; /* a char */ cp pnt; /* pointer to char */ carr chry; /* array of 100 char */
The general rule with the use of typedef is to write out a declaration as if you were declaring variables of the types that you want. Where a declaration would have introduced names with particular types, prefixing the whole thing with typedef means that, instead of getting variables declared, you declare new type names instead. Those new type names can then be used as the prefix to the declaration of variables of the new type.
The use of typedef isn't a particularly common sight in most programs; it's typically found only in header files and is rarely the province of day-to-day coding.
It is sometimes found in applications requiring very high portability: there, new types will be defined for the basic variables of the program and appropriate typedefs used to tailor the program to the target machine. This can lead to code which C programmers from other environments will find difficult to interpret if it's used to excess. The flavour of it is shown below:
/* file 'mytype.h' */ typedef short SMALLINT /* range *******30000 */ typedef int BIGINT /* range ******* 2E9 */ /* program */ #include "mytype.h" SMALLINT i; BIGINT loop_count;
On some machines, the range of an int would not be adequate for a BIGINT which would have to be re- typedef'd to be long.
To re-use a name already declared as a typedef, its declaration must include at least one type specifier, which removes any ambiguity:
typedef int new_thing;
func(new_thing x){
float new_thing;
new_thing = x;
}
As a word of warning, typedef can only be used to declare the type of return value from a function, not the overall type of the function. The overall type includes information about the function's parameters as well as the type of its return value.
/*
* Using typedef, declare 'func' to have type
* 'function taking two int arguments, returning int'
*/
typedef int func(int, int);
/* ERROR */
func func_name{ /*....*/ }
/* Correct. Returns pointer to a type 'func' */
func *func_name(){ /*....*/ }
/*
* Correct if functions could return functions,
* but C can't.
*/
func func_name(){ /*....*/ }
If a typedef of a particular identifier is in scope, that identifer may not be used as the formal parameter of a function. This is because something like the following declaration causes a problem:
typedef int i1_t, i2_t, i3_t, i4_t; int f(i1_t, i2_t, i3_t, i4_t)/*THIS IS POINT 'X'*/
A compiler reading the function declaration reaches point ‘X’ and still doesn't know whether it is looking at a function declaration, essentially similar to
int f(int, int, int, int) /* prototype */
or
int f(a, b, c, d) /* not a prototype */
—the problem is only resolvable (in the worst case) by looking at what follows point ‘X’; if it is a semicolon, then that was a declaration, if it is a { then that was a definition. The rule forbidding typedef names to be formal parameters means that a compiler can always tell whether it is processing a declaration or a definition by looking at the first identifier following the function name.
The use of typedef is also valuable when you want to declare things whose declaration syntax is painfully impenetrable, like ‘array of ten pointers to array of five integers’, which tends to cause panic even amongst the hardy. Hiding it in a typedef means you only have to read it once and can also help to break it up into manageable pieces:
typedef int (*a10ptoa5i[10])[5]; /* or */ typedef int a5i[5]; typedef a5i *atenptoa5i[10];
Try it out!
Source: The C Book – Typedef
Comments : Leave a Comment »
Categories : Programming
Rasmus’ 30 second AJAX Tutorial
6 02 2006I find a lot of this AJAX stuff a bit of a hype. Lots of people have
been using similar things long before it became “AJAX�. And it really
isn’t as complicated as a lot of people make it out to be. Here is a
simple example from one of my apps…..
See more on Rasmus’ 30 second AJAX Tutorial
Comments : Leave a Comment »
Categories : Programming
C++ vs Java vs Python vs Ruby
1 02 2006All about the comparison between C++, Java, Phyton and Ruby.
Here’s the link:
Comments : 1 Comment »
Categories : Programming