星期三, 十月 28, 2009
Java中如何得到网卡的IP地址而不是127.0.0.1
String ipaddress="";
java.util.Enumeration interfaces = java.net.NetworkInterface.getNetworkInterfaces();
while (interfaces.hasMoreElements())
{
java.net.NetworkInterface card = (java.net.NetworkInterface) interfaces.nextElement();
java.util.Enumeration addresses = card.getInetAddresses();
if (addresses == null)
continue;
while (addresses.hasMoreElements())
{
java.net.InetAddress address = (java.net.InetAddress) addresses.nextElement();
if(!address.isLoopbackAddress())//skip 127.0.0.1 address
{
if(address.isSiteLocalAddress())//yes,it,not NIC link address
{
ipaddress=address.getHostAddress();
break;
}
}
}
}
星期日, 十月 25, 2009
wxButton 如何捕获Enter回车事件
wxButton *toclip = new wxButton(books,ID_BUTTON_TO_CLIP, wxT("复制剪贴板"), wxPoint(x,y));
toclip ->Connect(wxEVT_COMMAND_BUTTON_CLICKED ,wxCommandEventHandler(GlobalEvtHandler::OnPagingHandler));
星期三, 十月 21, 2009
get jboss tomcat http server config port and SSL etc
发现Mbean的几个方法如下:
那个可以工作要看不同的jboss 版本。第一个一般是可以的
1.MBeanServer server = (MBeanServer) MBeanServerFactory.findMBeanServer(null).get(0);2.MBeanServer server = org.jboss.mx.util.MBeanServerLocator.locateJBoss();InitialContext ctx = new InitialContext(table); // From tablekeystoreFile="${user.home}/.keystore" keystorePass="changeit"
MBeanServerConnection server = (MBeanServerConnection) ctx.lookup("jmx/invoker/HttpAdaptor");
System.out.println("Version = "
+ (String)server.getAttribute(new ObjectName("jboss.system:type=Server"), new String("Version")));
JBOSS 允许SSL及配置的数字签名文件
早server.xml或tomcat config.xml文件中加入两个属性
然后到.keystore指定的目录下运行如下命令:
%JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA
跟随提示,密码同keystorePass属性指定的保持一致就可以了all is ok.
星期三, 十月 14, 2009
wxWidgets 连续打开两个Dialog造成exception的原因
代码如下:
原因:
Destroy();造成了异常。
只需要最后一次打开Dialog的时候,调用Destroy()就可以了。
不知道为什么,很奇怪。
最后发现:这样解决了一场问题,但是,引用程序不会退出了,挂死了!!!!
经过再次的研究,在每次点ok按钮 退出Dialog的时候,要调用:EndModal(wxID_OK);
奇怪之极。要加入
dlg.EndModal(wxID_OK);
dlg2.EndModal(wxID_OK);
{
wxDialog dlg;
dlg.Create(NULL, wxNewId(), _T("Step 1"),
wxDefaultPosition, wxSize(500,300));
wxPanel* bgpanel=new wxPanel(&dlg, wxID_ANY, wxDefaultPosition, wxSize(dlg.GetSize().GetWidth(),dlg.GetSize().GetHeight()), wxTAB_TRAVERSAL|wxWANTS_CHARS, _T("Step 1"));
wxButton* ok = new wxButton(bgpanel,wxID_OK,_("ok"),wxPoint(bgpanel->GetSize().GetWidth()/2-50,bgpanel->GetSize().GetHeight()-60));
dlg.ShowModal();
dlg.Destroy();
wxDialog dlg2;
dlg2.Create(NULL, wxNewId(), _T("Step 2"),
wxDefaultPosition, wxSize(500,300));
wxPanel* bgpane2=new wxPanel(&dlg2, wxID_ANY, wxDefaultPosition, wxSize(dlg2.GetSize().GetWidth(),dlg2.GetSize().GetHeight()), wxTAB_TRAVERSAL|wxWANTS_CHARS, _T("step 1"));
wxButton* ok2 = new wxButton(bgpane2,wxID_OK,_("ok"),wxPoint(bgpane2->GetSize().GetWidth()/2-50,bgpane2->GetSize().GetHeight()-60));
dlg2.ShowModal();
dlg2.Destroy();
}
星期四, 九月 03, 2009
wxDateTime时间格式
Name
strftime - format date and timeSynopsis
#include <time.h>The strftime() function formats the broken-down time tm according to the format specification format and places the result in the character array s of size max.
size_t strftime(char *s, size_t max, const char *format, const struct tm
*tm);
Ordinary characters placed in the format string are copied to s without conversion. Conversion specifications are introduced by a '%' character, and terminated by a conversion specifier character, and are replaced in s as follows:
- %a
- The abbreviated weekday name according to the current locale.
- %A
- The full weekday name according to the current locale.
- %b
- The abbreviated month name according to the current locale.
- %B
- The full month name according to the current locale.
- %c
- The preferred date and time representation for the current locale.
- %C
- The century number (year/100) as a 2-digit integer. (SU)
- %d
- The day of the month as a decimal number (range 01 to 31).
- %D
- Equivalent to %m/%d/%y. (Yecch -- for Americans only. Americans should note that in other countries %d/%m/%y is rather common. This means that in international context this format is ambiguous and should not be used.) (SU)
- %e
- Like %d, the day of the month as a decimal number, but a leading zero is replaced by a space. (SU)
- %E
- Modifier: use alternative format, see below. (SU)
- %F
- Equivalent to %Y-%m-%d (the ISO 8601 date format). (C99)
- %G
- The ISO 8601 year with century as a decimal number. The 4-digit year corresponding to the ISO week number (see %V). This has the same format and value as %y, except that if the ISO week number belongs to the previous or next year, that year is used instead. (TZ)
- %g
- Like %G, but without century, i.e., with a 2-digit year (00-99). (TZ)
- %h
- Equivalent to %b. (SU)
- %H
- The hour as a decimal number using a 24-hour clock (range 00 to 23).
- %I
- The hour as a decimal number using a 12-hour clock (range 01 to 12).
- %j
- The day of the year as a decimal number (range 001 to 366).
- %k
- The hour (24-hour clock) as a decimal number (range 0 to 23); single digits are preceded by a blank. (See also %H.) (TZ)
- %l
- The hour (12-hour clock) as a decimal number (range 1 to 12); single digits are preceded by a blank. (See also %I.) (TZ)
- %m
- The month as a decimal number (range 01 to 12).
- %M
- The minute as a decimal number (range 00 to 59).
- %n
- A newline character. (SU)
- %O
- Modifier: use alternative format, see below. (SU)
- %p
- Either 'AM' or 'PM' according to the given time value, or the corresponding strings for the current locale. Noon is treated as 'pm' and midnight as 'am'.
- %P
- Like %p but in lowercase: 'am' or 'pm' or a corresponding string for the current locale. (GNU)
- %r
- The time in a.m. or p.m. notation. In the POSIX locale this is equivalent to '%I:%M:%S %p'. (SU)
- %R
- The time in 24-hour notation (%H:%M). (SU) For a version including the seconds, see %T below.
- %s
- The number of seconds since the Epoch, i.e., since 1970-01-01 00:00:00 UTC. (TZ)
- %S
- The second as a decimal number (range 00 to 60). (The range is up to 60 to allow for occasional leap seconds.)
- %t
- A tab character. (SU)
- %T
- The time in 24-hour notation (%H:%M:%S). (SU)
- %u
- The day of the week as a decimal, range 1 to 7, Monday being 1. See also %w. (SU)
- %U
- The week number of the current year as a decimal number, range 00 to 53, starting with the first Sunday as the first day of week 01. See also %V and %W.
- %V
- The ISO 8601:1988 week number of the current year as a decimal number, range 01 to 53, where week 1 is the first week that has at least 4 days in the current year, and with Monday as the first day of the week. See also %U and %W. (SU)
- %w
- The day of the week as a decimal, range 0 to 6, Sunday being 0. See also %u.
- %W
- The week number of the current year as a decimal number, range 00 to 53, starting with the first Monday as the first day of week 01.
- %x
- The preferred date representation for the current locale without the time.
- %X
- The preferred time representation for the current locale without the date.
- %y
- The year as a decimal number without a century (range 00 to 99).
- %Y
- The year as a decimal number including the century.
- %z
- The time-zone as hour offset from GMT. Required to emit RFC 822-conformant dates (using "%a, %d %b %Y %H:%M:%S %z"). (GNU)
- %Z
- The time zone or name or abbreviation.
- %+
- The date and time in date(1) format. (TZ) (Not supported in glibc2.)
- %%
- A literal '%' character.
Some conversion specifications can be modified by preceding the conversion specifier character by the E or O modifier to indicate that an alternative format should be used. If the alternative format or specification does not exist for the current locale, the behaviour will be as if the unmodified conversion specification were used. (SU) The Single Unix Specification mentions %Ec, %EC, %Ex, %EX, %Ey, %EY, %Od, %Oe, %OH, %OI, %Om, %OM, %OS, %Ou, %OU, %OV, %Ow, %OW, %Oy, where the effect of the O modifier is to use alternative numeric symbols (say, roman numerals), and that of the E modifier is to use a locale-dependent alternative representation.
The broken-down time structure tm is defined in <time.h>. See also ctime(3).
Return Value
The strftime() function returns the number of characters placed in the array s, not including the terminating null byte, provided the string, including the terminating null byte, fits. Otherwise, it returns 0, and the contents of the array is undefined. (Thus at least since libc 4.4.4; very old versions of libc, such as libc 4.4.1, would return max if the array was too small.)Note that the return value 0 does not necessarily indicate an error; for example, in many locales %p yields an empty string.
Environment
The environment variables TZ and LC_TIME are used.Conforming to
SVr4, C89, C99. There are strict inclusions between the set of conversions given in ANSI C (unmarked), those given in the Single Unix Specification (marked SU), those given in Olson's timezone package (marked TZ), and those given in glibc (marked GNU), except that %+ is not supported in glibc2. On the other hand glibc2 has several more extensions. POSIX.1 only refers to ANSI C; POSIX.2 describes under date(1) several extensions that could apply to strftime() as well. The %F conversion is in C99 and POSIX.1-2001.In SUSv2, the %S specified allowed a range of 00 to 61, to allow for the theoretical possibility of a minute that included a double leap second (there never has been such a minute).
Glibc Notes
Glibc provides some extensions for conversion specifications. (These extensions are not specified in POSIX.1-2001, but a few other systems provide similar features.) Between the % character and the conversion specifier character, an optional flag and field width may be specified. (These precede the E or O modifiers, if present.)The following flag characters are permitted:
- _
- (underscore) Pad a numeric result string with spaces.
- -
- (dash) Do not pad a numeric result string.
- Pad a numeric result string with zeros even if the conversion specifier character uses space-padding by default.
- ^
- Convert alphabetic characters in result string to upper case.
- #
- Swap the case of the result string. (This flag only works with certain conversion specifier characters, and of these, it is only really useful with %Z).
An optional decimal width specifier may follow the (possibly absent) flag. If the natural size of the field is smaller than this width, then the result string is padded (on the left) to the specified width.
Bugs
Some buggy versions of gcc complain about the use of %c: warning: '%c' yields only last 2 digits of year in some locales. Of course programmers are encouraged to use %c, it gives the preferred date and time representation. One meets all kinds of strange obfuscations to circumvent this gcc problem. A relatively clean one is to add an intermediate functionsize_t my_strftime(char *s, size_t max, const char *fmt, const struct tm *tm) {
return strftime(s, max, fmt, tm);}
Example
The program below can be used to experiment with strftime().#include <time.h>Some examples of the result string produced by the glibc implementation of strftime() are as follows:
#include <stdio.h>
#include <stdlib.h>
int
main(int argc, char *argv[])
{
char outstr[200];
time_t t;
struct tm *tmp;
t = time(NULL);
tmp = localtime(&t);
if (tmp == NULL) {
perror("localtime");
exit(EXIT_FAILURE);
}
if (strftime(outstr, sizeof(outstr), argv[1], tmp) == 0) {
fprintf(stderr, "strftime returned 0");
exit(EXIT_FAILURE);
}
printf("Result string is \"%s\"\n", outstr);
exit(EXIT_SUCCESS);
} /* main */
$ ./a.out "%m"
Result string is "11"
$ ./a.out "%5m"
Result string is "00011"
$ ./a.out "%_5m"
Result string is " 11"
See Also
date(1), time(2), ctime(3), setlocale(3), sprintf(3), strptime(3)星期四, 八月 20, 2009
SQLITE 3支持多线程并发访问。
gcc -c sqlite3.c -o sqlite3.dll -DSQLITE_THREADSAFE=2
http://sqlite.org/threadsafe.html
星期三, 八月 19, 2009
gcc编译 vtable undefined reference错误
但是这种定义,在link的时候出现 vtable ..undefined reference to 的错误,原因是gcc实现
C++规范的时候的问题,解决这个问题,是需要必须顶一个空的virtual,这样造成了,编译器
检查强迫子类覆盖的失效,非常的不爽。virtual myfunction (){}; 语法来规避错误
有人建议使用 virtual myfunction ()=0;但没有成功
http://gcc.gnu.org/faq.html#vtables
class Port { private: char *brand; char style[20]; // i.e. tawny, ruby, vintage int bottles; public: Port(const char *br = "none", const char *st = "none", int b = 0); Port(const Port &p); // copy constructor virtual ~Port() { delete [] brand;} Port & operator=(const Port &p); Port & operator+=(int b); Port & operator-=(int b); int BottleCount() const {return bottles;} virtual void Show() const; friend ostream &operator<<(ostream &os, const Port &p); }; class VintagePort : public Port { private: char * nickname; // i.e. The Noble, or Old Velvet, etc. int year; // vintage year public: VintagePort(); VintagePort(const char *br, int b, const char *nn, int y); VintagePort(const VintagePort &vp); ~VintagePort() {delete [] nickname;} void Show() const; friend ostream & operator<<(ostream &os, const VintagePort & vp); };
星期六, 八月 15, 2009
wxWidgets RTTI 使用
然后再c++中载入该类.经过研究,发现wxWidgets支持RTTI。
首先需要在编译选项中加入wxUSE_EXTENDED_RTTI选项,
然后使用类似下面的方法:
#ifndef AIBASE_H
#define AIBASE_H
#include
#include
class AIBase:public wxObject,public wxThread
{
public:
AIBase();
~AIBase();
virtual void *Entry();//logic code in here
virtual void OnExit();
protected:
private:
DECLARE_DYNAMIC_CLASS(AIBase);
};
#endif // AIBASE_H
注意类必须继承来自wxObject,而且必须加入public的修饰符。
否则继承自AIBase的子类会出现,
is an inaccessible base of 'wxObject'
注意:
IMPLEMENT_DYNAMIC_CLASS用在实现的CPP 代码文件中
http://wiki.wxwidgets.org/RTTI
星期三, 八月 05, 2009
wxWidgets动态事件表
使用动态事件映射方法的原因,可能是你想在程序运行的不同时刻使用不同的映射关系,或者因为你使用的那种语言(例如python)不支持静态映射,或者仅仅是因为你更喜欢动态映射。因为动态映射的方法可以使你更精确的控制事件表的细节,你甚至可以单独的将事件表中的某一个条目在运行期打开或者关闭,而前面说的PushEventHandler和PopEventHandler的方法只能针对整个事件表进行处理。除此以外,动态事件处理还允许你在不同的类之间共享事件函数。
——《WxWidgets跨平台GUI开发》
导言
在wxWidgets中,相对于静态事件表那种僵死并且不知其所以然的方法,我更喜欢动态事件表,亲自Connect,还可以随时Disconnect。
但是,在写动态事件表时,会遇到一个问题,wxWidgets的官方文档中的事件处理部份,对于静态事件表所需的各种事件类型的宏叙述详尽,却对动态事件表所需的事件类型语焉不详,这给我们的使用带来了麻烦。需要的知识一方面零星分布于wx文档中,另一方面被冗长的代码掩映在
大部份写GUI常用的wx类(包括窗口、对话框、控件)都继承于三个类:wxWindowwx、wxEvtHandler、wxObject。因此,大多数情况下,这三个类的成员函数是我们可以顺手牵过来用的。动态事件表的使用中,最为重要的函数Connect和Disconnect就是 wxEvtHandler的成员函数,我们可以牵过来给我们手头这个要处理事件的wx类用。
先看看官方文档里对Connect函数的介绍(我对其进行了翻译、精简,有时,为了解释的明晰,作一些补充说明):
#TRANSLATE BEGIN
wxEvtHandler::Connect
Connect函数被重载了三次,各有各的用途。
第一个版本:范围捕杀 ( [id, lastid] 且 eventType)
void Connect(int id, int lastId, wxEventType eventType, wxObjectEventFunction function, wxObject* userData = NULL, wxEvtHandler* eventSink = NULL)
第二个版本:精确狙击(id 且 eventType)
void Connect(int id, wxEventType eventType, wxObjectEventFunction function, wxObject* userData = NULL, wxEvtHandler* eventSink = NULL)
第三个版本:分门别类 (仅 eventType)
void Connect(wxEventType eventType, wxObjectEventFunction function, wxObject* userData = NULL, wxEvtHandler* eventSink = NULL)
该函数动态地将所给事件处理函数 与 EventHandler、ID 甚至事件类型联系起来。这是静态事件表的一种替代选择。
按:EventHandler直译为事件处理器,或可译为“事件手柄”(生动地模仿句柄)?后文使用“事件手柄”。
参数意义:
id
你要和事件处理函数联系起来的ID(可以是窗口ID、菜单ID、控件ID)。对于没有这个参数的重载版本,id被默认设为 wxID_ANY。
当和lastid连用时,表达的是一个ID范围,即大小介于id和last id之间的所有ID,都会被Connect函数与事件处理函数联系起来。
按:实在没必要连“ID”都译成“标识符”……其实看技术文档时,我最头痛的是一堆汉字堆在那里,包括看数学书时……
lastId
参见id中的介绍。
eventType
你要和事件处理函数联系起来的Event Type。按:Event Type直译为“事件类型”并不恰当,因为事件类型是指形如wxMouseEvent这样的东西,而这里所指,是形如wxEVT_MOTION这样的东西。准确地说,应该称之为“事件标识符”或“事件ID”。下文使用“事件ID”。一个事件类型里,会有若干事件ID,比wxMouseEvent里除了wxEVT_MOTION,还有wxEVT_LEFT_DOWN等等等事件ID。 因此可以把事件ID作为对事件类型的一个细分。
function
事件处理函数。注意这个函数应当被显式转换为正确的类型。对于类型为wxFooEvent的事件,转换使用宏wxFooEventHandler。
userData
你要和事件表项联系起来的数据。(暂时我还不知道这个有什么用)
eventSink
告诉Connect函数,你要调用的事件处理函数是谁的成员函数。如果该参数为 NULL, 那么Connect函数将使用this指针 。按:正是这个参数允许了我们在不同类中共享事件处理函数。
例子:frame->Connect( wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MyFrame::OnQuit) );对例子的解释:wxID_EXIT是之前赋给了某一个菜单项的ID。当该菜单被选择时,会产生一个ID为wxEVT_COMMAND_MENU_SELECTED的事件。因此MyFrame::OnQuit在被显式转换为wxCommandEventHandler型的“事件手柄”之后,被Connect拉过来处理该事件。 #TRANSLATE END
就不再翻译Disconnect函数的文档了,因为除了函数名不同,它的所有参数和Connect是一模一样的。它的用途就是断开Connect所建立起来的联系。
实践中写事件处理的时候,通常使用的是Connect的后两种重载版本。参数userData和eventSink的使用是比较少的,而且也有默认值,一般不去理它就可以了。
参数id是你赋给产生了这个事件的窗口、菜单或控件的,你自己心里是清楚的。问题顶多是,你需要使用系统默认的那些ID(比如上面例子里的 wxID_EXIT),而你不知道哪个还哪个。那些ID的列表在官方文档里是有的,不过为了本文作为手册的完整性,将在本文最后给出。
有时是不需要id的,比如鼠标移动的事件:
frame->Connect(wxEVT_MOTION,wxMouseEventHandler(MyFrame::OnMouseMove));
直接把事件ID与事件手柄联系起来。 参数function的问题大一些,就是这个显式强制类型转换的这个Handler,具体叫wx什么EventHandler呢?这个问题也好解决,因为官方文档里的 Classes By Category里的Event小节已经给出了形如wxFooEvent这样的事件类型的列表,只需要在相应的事件类型后面加上Handler就可以了。同样为了本文作为手册的完整性,将在本文后面给出全部Handler的列表。
最大的问题出在参数eventType上。形如wxEVT_MOTION、wxEVT_COMMAND_MENU_SELECTED这样的事件ID的名字,我们从何得知?这些奇形怪状的名字,纵然我们英语很强,也未必能造出和wxWidgets定义的一模一样的名字啊。比如写惯MFC的同好们很容易将鼠标移动事件ID写为wxMOUSEMOVE或wxMOUSE_MOVE,可这却是错的。最糟糕的是,文档中没有提供这些名字的列表!
有些同好可能发现了,对大部份事件类型的静态事件表的宏的说明中,包含了这方面的重要信息,例如wxPaintEvent里:
EVT_PAINT(func) Process a wxEVT_PAINT event.
左边是静态事件表需要的,右边是动态事件表需要的。左手静态,右手动态,好潇洒啊!然而,倘若你要处理窗口关闭事件(假设该事件的产生不是通过菜单选择,而是点窗口右上角的红叉叉),你跑到wxCloseEvent那里一看:
EVT_CLOSE(func) Process a close event, supplying the member function. This event applies to wxFrame and wxDialog classes.
你晕了……为什么文档编写者连这都不肯告诉你?!于是你尝试着用wxEVT_CLOSE,编译器告诉你不对。已经习惯了没事翻翻头文件的你就跑到
所幸这个情况并没有出现在大多数基本的事件里,但实际中总会需要处理那些不那么基本的事件的,每次都在这个细节上卡这么久的壳太不划算了。所以我把事件 ID列表从
。
星期二, 八月 04, 2009
wxWidgets-2.8.10 undefined reference to `wxXmlResource::LoadIconW(wxString const
wxXmlResource::Get()->LoadIcon(_T("appIco"));
链接的时候出现:
undefined reference to `wxXmlResource::LoadIconW(wxString const|
这个错误非常的奇怪,只是包含wx/xrc/xmlres.h,则出现这个错误
经过分析发现LoadIconW在wx/msw/winundef.h中有如下定义:
#ifdef LoadIcon
#undef LoadIcon
inline HICON LoadIcon(HINSTANCE hInstance, LPCTSTR lpIconName)
{
#ifdef _UNICODE
return LoadIconW(hInstance, lpIconName);
#else // ANSI
return LoadIconA(hInstance, lpIconName);
星期一, 七月 20, 2009
c string to wxstring
c++ string如何转换为wxString就需要耐心。
这里是一些文章:
http://wiki.wxwidgets.org/WxString#Converting_a_Normal_String_to_a_wxString
实际的语法是这样的:
string result="hello world";
wxMessageBox(wxString(result.c_str(), wxConvUTF8));
char* chars = "你好,世界!";
c string to wxstring
c++ string如何转换为wxString就需要耐心。
这里是一些文章:
http://wiki.wxwidgets.org/WxString#Converting_a_Normal_String_to_a_wxString
实际的语法是这样的:
string result="hello world";
wxMessageBox(wxString(result.c_str(), wxConvUTF8));
boost 编译如何做?
在编译之前,必须首先装了cybgin或mingw或者visual c++ studio 2008,免费版本的可以在网络上直接下载.
在编辑boost必须手边编译好bjam.
这个在下载的boost 1.39解压缩的包里的:boost_1_39_0\tools\jam
在安装了vs c++ studio 2008或gcc之后就可以直接运行:build_dist.bat
如果要gcc.修改文件最后一句call .\build.bat 为 call .\build.bat gcc
就可以了。
boost编译完后,可以把所有lib和头文件复制到一个指定的目录下
这个动作需要在命令行指定install 参数
编译好bjam后,复制到安装的boost根目录下.
然后可以直接运行bjam了。
标准编译的,支持多线程,用gcc编译,编译的选项包括:
bjam install --toolset=gcc --prefix="c:\boost_1_38_0" release toolset=gcc threading=multi link=static
注意:如果不指定toolset和prefix选项,boost默认使用 mscv编译
和c:\boost_1_39_0目录安装
boost编译支持的选项可以通过bjam --help 来查看。意思如下:--build-dir=
--stagedir=
--build-type=complete 编译所有版本(确切地说是相当于:variant=release, threading=multi;
link=shared|static;runtime-link=shared)
variant=debug|release 编译什么版本(Debug or Release?)
link=static|shared 使用静态库还是动态库。
threading=single|multi 单线程还是多线程库。
runtime-link=static|shared 决定是静态还是动态链接C/C++标准库。
--with-
--show-libraries 显示需要编译的库名称
星期五, 七月 10, 2009
wxGrid如何catch key event?
想让wxGrid catch 键盘事件,比如光标,必须在建立wxGrid的时候,需要加入wxWANTS_CHARS.
Grid1 = new wxGrid(Panel1, ID_GRID1, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS, _T("ID_GRID1"));
其次:
加入事件定义,比如如下:
Connect(ID_GRID1,wxEVT_GRID_SELECT_CELL,(wxObjectEventFunction)&bonusFrame::OnGrid1CellLeftClick);
如下:
void bonusFrame::OnGrid1CellLeftClick(wxGridEvent& ev)
{
wxLogMessage(_T("Left click at row %d, col %d"), ev.GetRow(), ev.GetCol());
ev.Skip();//必须的。
}
这样就可以获得键盘光标事件了
经过一些列的需求驱动,发现了如何在wxFrame下,如何定义热键的方法
wxWidgets设计的非常的糟糕。
这里的文章很全面:
http://wiki.wxwidgets.org/Catching_key_events_globally
星期三, 七月 01, 2009
如何在唯一的wxWidgets执行文件中包含资源数据的步骤
编写xrc文件,手工编写是要让人崩溃的,可以下载http://wxformbuilder.org/ 下载用来 工具制作xrc文件 wxWidgets for C++从资源文件中静态装载图像 | |
| 在wxWidgets中装载图像是非常容易的,但是如果将图像文件和可执行文件放到一起,在发布时只需要发布可执行文件,要实现这种功能,一般可以使用资 源文件来解决。在windows下的资源文件的源文件是*.rc,编译后叫*.res。在linux下类似,源文件为*.xrc,编译后叫*.xres。 但它们是xml格式的,要装载这种资源文件也得动态进行装载。相当于配置文件。 如果想将其直接编译进可执行文件。需要一个工具wxrc。这个工作在wxWidgets中的utils/wxrc目录中,可自己编译,mingw32-make -f makefile.gcc UNICODE=1 BUILD=release。可使用这个工具将*.xrc 生成c++代码,如果是图像,就将其转换成字符数组。然后和其它程序一起进行编译。可使用wxrc -c main.xrc -v -o main.h main.xrc的格式如下: <?xml version="1.0"?> <resource version="2.3.0.1"> <object class="wxBitmap" name="background">background.jpg</object> </resource> 生成的main.h的格式如下: // // This file was automatically generated by wxrc, do not edit by hand. // #include <wx/wxprec.h> #ifdef __BORLANDC__ #pragma hdrstop 在Visual C++的项目中添加XRC文件 虽然wxWidgets提供了XRC文件的编译器,但是把XRC的文件直接添加到Visual C++的项目中的话确没有任何效果,因为Visual C++默认能够处理的文件类型并不包含XRC文件。其实通过Visual C++的"自定义生成步骤"可以让XRC文件被自动编译:引用:
6 获得Windows应用程序实例句柄 声明如下函数:代码: extern "C" |
wxGridCellAttr SetTextColour windowXP得到异常
wxGridCellAttr *attrRed = new wxGridCellAttr();
attrRed->SetTextColour(wxColour(wxT("#0000ff")));
得到异常。
修改为以下语句则正常工作:
attrRed->SetTextColour(wxColour(0,0,255));
class静态成员变量link时候出现 undefined reference 错误
头文件
a.h
class a
{
public:
static string a;
}
a.cpp
// declare class static objects
string a::format;
这样就可以解决这种link出现的 undefined reference 的错误
星期六, 六月 27, 2009
如何处理CodeBlock编译链接出现undefined rererence 的错误.
这种错误,是codeblock的一个bug.
需要把 链接的库加载项目的的鼠标右键的properties..里,而不是build options..里
选择properties打开project/target options窗口,右下角的按钮 Project's build options...打开
Project build options窗口,这个窗口同项目鼠标右键菜单中的build options竟然不同一,所以在设置中往往
在“正确”设置后,出现了错误,这两个窗口往往都需要同时设置,从最后产生的编译命令行分析,不过是重复加入,实在是奇怪。
需要把mingw\lib下面的库和wxWidges lib\gcc_lib或gcc_dll下面的库都加入到 ,Link setting 下的link Libraries 里,全部加入
星期五, 六月 26, 2009
JBOSS通过JAAS框架验证用户后,如何得到用户所有的角色?
private void findRole() throws PolicyContextException {
// Get the Authenticated Subject
Subject subject = (Subject) PolicyContext.getContext("javax.security.auth.Subject.container");
// Now look for a Group called Roles
Set principals = subject.getPrincipals(Principal.class);
Iterator iter = principals.iterator();
while(iter.hasNext()) {
Principal p = (Principal)iter.next();
if(p instanceof SimpleGroup) {
SimpleGroup sg = (SimpleGroup)p;
if("Roles".equals(sg.getName())) {
Enumeration en = sg.members();
while(en.hasMoreElements()) {
String role = en.nextElement().toString();
if(role != null) {
setRole(role);
}
}
}
}
}
}
星期一, 六月 22, 2009
如何在wxWidgets 编译生成wxdbgrid组件
wxWidgets-2.8.10\build\msw>mingw32-make -f makefile.gcc UNICODE=1 BUILD=release MONOLITHIC=0 USE_ODBC=1 USE_GUI=1
则lib\gcc_lib下得到libwxmsw28u_dbgrid.a
星期四, 六月 11, 2009
如何用cygwin在控制台 显示彩色的字符
Linux的API的库,这样造成了一些现实彩色字符的不同技术。
cygwin.dll直接至此ANSI 颜色控制,支持ESC 累得颜色编码,所以直接用printf("\033[1;34m hello \033[0m“)就可以打印出一个蓝色的字符串了。
但是如果不是用cygwin.dll,而是通过-mno-cygwin编译选项,是用window crt.dll库,则ANSI颜色控制码失去了作用。此时必须使用window下的方法。
所以,这就要求代码能区别本程序的依赖,是否使用了-mno-cygwin编译出来的代码。
通过深入研究,发现了 -mno-cygwin编译的依赖宏,并在自己的程序根据是否有特定的宏的出现,作为信号灯来识别。
步骤如下:
发现编译器预编译的宏
g++-3 -E -dM -mno-cygwin -c testdb.cpp >2.txt
生成编译器预编译文件,发现了定义的宏,通过搜索发现了:__MINGW_H 宏。
因此在自己的文件中加入:
#ifdef __MINGW_H
static int MINGW_FLAG=1;
#else
static int MINGW_FLAG=0;
Linux ANSI 颜色控制
在C语言中,可以通过printf直接打印出控制符号
ANSI控制码的说明
具体的摘抄一些如下:
[0m 关闭所有属性
[1m 设置高亮度
[4m 下划线
[5m 闪烁
[7m 反显
[8m 消隐
[30m -- [37m 设置前景色
[40m -- [47m 设置背景色
[nA 光标上移n行
[nB 光标下移n行
[nC 光标右移n行
[nD 光标左移n行
[y;xH设置光标位置
[2J 清屏
[K 清除从光标到行尾的内容
[s 保存光标位置
[u 恢复光标位置
[?25l 隐藏光标
[?25h 显示光标
星期日, 六月 07, 2009
SQLITE 使用g++来编译
http://www.mail-archive.com/sqlite-users@sqlite.org/msg30132.html
SQLite is ANSI C, so youshould compile it with gcc. It will still be usable within your C++library/project, as sqlite3.h qualifies all functions extern "C".
gcc -c sqlite3.c
g++ -c main.cpp
g++ -o program main.o sqlite3.o -lpthread -ldl
星期五, 五月 01, 2009
Netbean 6.5 同cygwin c/c++ 工作生成独立.exe文件
cygwin编译生成的.exe在命令行运行的时候,会出现 需要 cygwin1.dll的提示。
非常的不方便.exe的发布。
根据提示可以在c/c++的项目 c++ 编译器里 额外的选项里加入 -mno-cygwin来利用mingw生成独立的.exe
并避免协议法律上的问题。
如图:
不过需要安装的额外的包包含如下:
通过http://cygwin.com/setup.exe 安装如下包
http://wiki.openttd.org/Cygwin
- binutils: The GNU assembler, linker and binary utilities
- gcc: C compiler
- gcc-g++: GCC C++ compiler
- gcc-mingw-core: Mingw32 support headers and libraries for GCC
- gcc-mingw-g++: Mingw32 support headers and libraries for GCC C++
- make: The GNU version of the 'make' utility
- mingw-runtime: MinGW Runtime
- subversion: A version control system
- In the Libs section, you will need:
- crypt: Encryption/Decryption utility and library
- zlib: The zlib compression and decompression library
- mingw-runtime: MinGW Runtime
- w32api: Win32 API header and library import files
- In the Mingw section, you will need:
- mingw-zlib: mingw version of the zlib compression and decompression library.
- Optionally you might want to install:
- libpng12-devel from the Grahpics section for making PNG screenshots and loading PNG heightmaps.
- libfreetype2-devel from the Devel section for using Windows' font in OpenTTD.
星期二, 四月 28, 2009
Visual C++ Express 2008 快捷键
F7,生成解决方案(生成.exe 或项目目标)
F5,运行当前解决方案
编辑快捷键
Shift+Alt+Enter: 切换全屏编辑 Ctrl+B,T / Ctrl+K,K: 切换书签开关
Ctrl+B,N / Ctrl+K,N: 移动到下一书签 Ctrl+B,P: 移动到上一书签
Ctrl+B,C: 清除全部标签 Ctrl+I: 渐进式搜索
Ctrl+Shift+I: 反向渐进式搜索 Ctrl+F: 查找
Ctrl+Shift+F: 在文件中查找 F3: 查找下一个
Shift+F3: 查找上一个 Ctrl+H: 替换
Ctrl+Shift+H: 在文件中替换 Alt+F12: 查找符号(列出所有查找结果)
Ctrl+Shift+V: 剪贴板循环 Ctrl+左右箭头键: 一次可以移动一个单词
Ctrl+上下箭头键: 滚动代码屏幕,但不移动光标位置。 Ctrl+Shift+L: 删除当前行
Ctrl+M,M: 隐藏或展开当前嵌套的折叠状态 Ctrl+M,P: 停止大纲显示
Ctrl+M,L: 将所有过程设置为相同的隐藏或展开状态 Ctrl+E,S: 查看空白
Ctrl+E,W: 自动换行 Ctrl+G: 转到指定行
Shift+Alt+箭头键: 选择矩形文本 Alt+鼠标左按钮: 选择矩形文本
Ctrl+Shift+U: 全部变为大写 Ctrl+U: 全部变为小写
代码快捷键
Ctrl+J / Ctrl+K,L: 列出成员
Ctrl+Shift+空格键 / Ctrl+K,P: 参数信息
Ctrl+K,I: 快速信息
Ctrl+E,Ctrl+C / Ctrl+K,Ctrl+C: 注释选定内容
Ctrl+E,Ctrl+U / Ctrl+K,Ctrl+U: 取消选定注释内容
Ctrl+K,M: 生成方法存根
Ctrl+K,X: 插入代码段 Ctrl+K,S: 插入外侧代码
F12: 转到所调用过程或变量的定义 tab两次: 代码补齐
Alt+鼠标左按钮: 选择矩形文本
Ctrl+Shift+U: 全部变为大写
Ctrl+U: 全部变为小写
窗口快捷键
Ctrl+W,W: 浏览器窗口 Ctrl+W,S: 解决方案管理器 Ctrl+W,C: 类视图
Ctrl+W,E: 错误列表 Ctrl+W,O: 输出视图 Ctrl+W,P: 属性窗口
Ctrl+W,T: 任务列表 Ctrl+W,X: 工具箱 Ctrl+W,B: 书签窗口
Ctrl+W,U: 文档大纲 Ctrl+D,B: 断点窗口 Ctrl+D,I: 即时窗口
Ctrl+Tab: 活动窗体切换 Ctrl+Shift+N: 新建项目 Ctrl+Shift+O: 打开项目
Ctrl+Shift+S: 全部保存 Shift+Alt+C: 新建类 Ctrl+Shift+A: 新建项
VC++ Express 2008 和SQLite 一起工作
目前网络上的版本都不够及时更新,所以是个大问题。这里是比较出名的cppsqlite
http://www.codeproject.com/KB/database/CppSQLite.aspx?fid=34722&df=90&mpp=25&noise=3&sort=Position&view=Quick&fr=26
SQLITE网站上有如何编译的步骤:
http://www.sqlite.org/cvstrac/wiki?p=HowToCompile
http://www.sqlite.org/download.html 这里搜索dll可以发现最新的dll .zip下载。里面包含一个.def的文件
这个需要在安装VC++ Express 2008后,在命令行用lib来注册
星期一, 三月 30, 2009
MYSQL JDBC CachedRowSetImpl 临时表错误
In a stored procedure, if a result set is selected from a temporary table and then
deleted, a MySQLSyntaxErrorException occurs from the driver trying to perform SHOW FULL
COLUMNS on the non-existent temporary table.
解决方法:在mysql URL 里加入:
"useDynamicCharsetInfo=false"
Jboss deploy/mysql-ds.xml里加入如下语句:
<connection-url>jdbc:mysql://localhost:3306/mrp?useUnicode=TRUE</connection-url>
<connection-property name="characterEncoding">utf8</connection-property>
<connection-property name="useDynamicCharsetInfo">false</connection-property>
星期二, 三月 24, 2009
Windows环境下配置Apache 2.2.x + SSL
Win32 Binary including OpenSSL 0.9.8i (MSI Installer): apache_2.2.11-win32-x86-openssl-0.9.8i.msi [PGP] [MD5]
2.在安装目录bin下生成证书
openssl req -new -x509 -nodes -keyout server.key -out server.crt -subj /C=US/ST=Desert/L=SnakeTown/O=SnakeOilCo/OU=IT/CN=snakeoil.com -config ../conf/openssl.cnf
3.配置apache支持SSL
----------
设置Apache支持SSL
----------
注意: 本设置步骤针对针对Apache 2.2.x版本, 如果正在使用的是Apache 2.0.x版本, 请摸索相似的设置.
在Apache的conf目录中用文本编辑器打开httpd.conf
1. 去掉下面设置行前面的#
3. 在Apache的conf/extra目录中打开httpd-ssl.conf, 更改如下设置. [apache安装目录]是指Apache的安装目录, 比如c:/Apache; my-server的两个文件就是前一个步骤制作的文件, 文件的位置就是这些文件在磁盘中的位置 (在2.0.x版本中这些设置仍然在 httpd.conf文件中进行)
SSLCertificateFile "[Apache安装目录]/conf/ssl/my-server.der.crt"
SSLCertificateKeyFile "[Apache安装目录]/conf/ssl/my-server.key"
4.测试
----------
测试
----------
1. 保存设置文件
2. 在开始菜单中运行Apache的Test Configuration工具, 检查设置文件是否正确
3. 重新启动Apache 2.2.x
4. 顺利启动之后, 在浏览器中输入 https://localhost 看看是否可以访问, 如果可以访问, 则设置成功!
星期五, 一月 09, 2009
SQLITE超强select case语法
select case
when red1%7=0 or red2%7=0 or red3%7=0 or red4%7=0 or red5%7=0 or red6%7=0 then 7
when red1%9=0 or red2%9=0 or red3%9=0 or red4%9=0 or red5%9=0 or red6%9=0 then 9
when red1%11=0 or red2%11=0 or red3%11=0 or red4%11=0 or red5%11=0 or red6%11=0 then 11
else term
end as result,rowid,count(*)
from _DBHISTORY group by result
2.标准switch case
select column_value case
when 1 then 1
when 2 then 2
else
3
end as result,rowid
from tableName
星期四, 十二月 25, 2008
文本聚类算法TCUSS(Text clustering using semantic similarity)
动态规划(dynamic programming)是运筹学的一个分支,是求解决策过程(decision process)最优化的数学方法
动态规划求解最长公共子串问题
算法思想
求字符串str1,str2的最长公共子串的长度。
定义二元函数函数f(m,n):分别以str1[m],str2[n]结尾的连续公共子串的长度
而对于f(m+1,n+1) 有以下两种情况
1.str1[m+1] != str2[n+1],则有f(m+1,n+1) =0
2.str1[m+1] == str2[n+1],则有f(m+1,n+1) = f(m,n) + 1
另外f(0,j) = 0(j>=0)
f(j,0) = 0 (j>=0)
按照上面这个公式,我们用容易写出这个算法的实现
算法实现
1 int commstr(char *str1, char *str2)
2 /* 返回str1,str2的最长公共之串长度*/
3 {
4 int len1=strlen(str1),len2=strlen(str2),row,col,max=0;
5 int **pf = new int*[len1+1];//动态分配一个二维数组作为辅助空间
6 for (row=0; row
7 pf[row] = new int[len2+1];
8
9 //数组赋初值
10 for (row=0; row
11 pf[row][0] = 0;
12 for (col=0; col
13 pf[0][col] = 0;
14
15 for (row=1; row<=len1; row++)
16 for (col=1;col<=len2; col++)
17 {
18 if (str1[row-1] == str2[col-1])
19 {
20 pf[row][col] = pf[row-1][col-1] + 1;
21 max = pf[row][col] > max ? pf[row][col] : max;
22 }
23 else
24 pf[row][col] = 0;
25 }
26 //空间回收
27 for (row=0; row
28 delete[] pf[row];
29 delete[] pf;
30
31 return max;
32 }
程序的输出
字符串"blog.csdn.net"和"csdn.blog"求公共子串时的输出结果
String:
1. blog.csdn.net
2. csdn.blog
c s d n . b l o g
0 0 0 0 0 0 0 0 0 0
b 0 0 0 0 0 0 1 0 0 0
l 0 0 0 0 0 0 0 2 0 0
o 0 0 0 0 0 0 0 0 3 0
g 0 0 0 0 0 0 0 0 0 4
. 0 0 0 0 0 1 0 0 0 0
c 0 1 0 0 0 0 0 0 0 0
s 0 0 2 0 0 0 0 0 0 0
d 0 0 0 3 0 0 0 0 0 0
n 0 0 0 0 4 0 0 0 0 0
. 0 0 0 0 0 5 0 0 0 0
n 0 0 0 0 1 0 0 0 0 0
e 0 0 0 0 0 0 0 0 0 0
t 0 0 0 0 0 0 0 0 0 0
max substr length:5
这是程序的输出结果,请注意红色字体
时间空间复杂度分析
如果用n,m表示两个字符串的长度的话,那么算法的
时间复杂度为O(n*m),空间复杂度也为O(n*m)
附:完整的源程序g++编译通过
#include
#include
void print_table(char *str1,char *str2,int **pf)
{
int i,j,row,col;
row = strlen(str1);
col = strlen(str2);
printf("\t\t");
for (i=0; i
printf("%c\t",str2[i]);
for (i=0; i<=row; i++)
{
for (j=0; j<=col; j++)
{
if (j == 0)
{
printf("\n");
if (i)
printf("%c\t",str1[i-1]);
else
printf("\t");
}
printf("%d\t",pf[i][j]);
}
}
}
int commstr(char *str1, char *str2)
/* 返回str1,str2的最长公共之串长度*/
{
int len1=strlen(str1),len2=strlen(str2),row,col,max=0;
int **pf = new int*[len1+1];//动态分配一个二维数组作为辅助空间
for (row=0; row
pf[row] = new int[len2+1];
//数组赋初值
for (row=0; row
pf[row][0] = 0;
for (col=0; col
pf[0][col] = 0;
for (row=1; row<=len1; row++)
for (col=1;col<=len2; col++)
{
if (str1[row-1] == str2[col-1])
{
pf[row][col] = pf[row-1][col-1] + 1;
max = pf[row][col] > max ? pf[row][col] : max;
}
else
pf[row][col] = 0;
}
print_table(str1,str2,pf);
//空间回收
for (row=0; row
delete[] pf[row];
delete[] pf;
return max;
}
int main(int argc,char **argv)
{
if (argc >= 3)
{
printf("String:\n\t1. %s\n\t2. %s\n",argv[1],argv[2]);
printf("\nmax substr length:%d\n",commstr(argv[1],argv[2]));
}
return 0;
}
星期三, 十二月 24, 2008
数据库自我关联
select a.*,b.* from _dbhistory a left join _dbhistory b on a.rowid=(b.rowid-1)
星期五, 十一月 21, 2008
DhtmlxGrid 错误跟踪
{
//custom code can be placed here
return false;
}
dhtmlxError.catchError("LoadXML", myErrorHandler);
星期三, 十一月 19, 2008
星期一, 十一月 17, 2008
MathType快捷键
插入一个上标:Ctrl+H
插入一个下标:Ctrl+L
Right arrow with upper text slot (Ctrl+T,Shift+Right) , 输入条件推理
Right arrow with lower text slot (Ctrl+T,CtrlAlt+Right) 输入条件推理
Right arrow with upper and lower text slots (Ctrl+T,Right) 输入条件推理
Curly brackets 大括号{
Left-pointing angle brackets 向左的尖括号<
Right-pointing angle bracket from Symbol style (Ctrl+Shift+K,>)
Left white square bracket from Extra Math style (Ctrl+Shift+K,[)
星期四, 十一月 06, 2008
Java JPopupMenu selection 丢失。
简单使用如下方法就可以了:
jpopup.setInvoker(jpopup);
如果想修改selection的颜色,可以使用如下方法,
UIManager.put("MenuItem.selectionBackground", Color.YELLOW);
星期三, 十一月 05, 2008
小窍门:Java如何让一个窗体显示在最上面?
使用这个方法可以做到。
如何在任何地方得到鼠标的的屏幕坐标?
jdk 6.0提供MouseInfo.getPointerInfo() .getLocation() 得到Point.getX(),.getY()
星期六, 十一月 01, 2008
如何选择JTable中任一行和任一列?
table.setModel(dayModel);
table.setCellSelectionEnabled(true);
table.getSelectionModel().setSelectionInterval(2, 2);
table.getColumnModel().getSelectionModel().setSelectionInterval(3, 3);
你可以修改上面的2行,3列为你自己的任一行或列。非常的easy
星期一, 十月 27, 2008
如何提高SQLITE JDBC大批量插入数据的速度?
类似语句如下:
stmt.execute("BEGIN");
for(int i=0;i<commands.length;i++)
{
stmt.addBatch(commands[i]);
}
stmt.executeBatch();
stmt.execute("end");
曾经大约800数据,使用默认方法插入,大概需要141秒,而采用新方法后,使用纯Java的JDBC
速度提高到4秒,而使用JNI的JDBC,速度提高到几乎可以忽略不计的地步。
Very nice.!!!
星期五, 十月 24, 2008
Java JScrollPane getVerticalScrollBar.setValue没有效果解决方法。
toolTip.getContentPane().add(scroll);
toolTip.pack();
//以下代码可以让scroll滚动到top顶端。
SwingUtilities.invokeLater(new Runnable(){public void run()
{
scroll.getVerticalScrollBar().setValue(0);
}
});
星期四, 十月 23, 2008
Servlet download 如何为已知的 MIME 类型激活“文件下载”对话框?
参考如下:
您可以使用 Content-disposition 头来覆盖此默认行为。其格式是:
Content-disposition: attachment; filename=fname.ext
ASP:代码
Response.AddHeader "content-disposition","attachment; filename=fname.ext"
Servlet代码:
realName="yourfiel.n";
response.addHeader("Content-disposition","attachment; filename="+realName);
//realName如果是汉字编码会造成出现不了制定的文件名的情况,需要编码
//把以上代码修改为
//response.addHeader("Content-disposition","attachment; filename="+java.net.URLEncoder.encode(realName,"UTF-8"));
response.setIntHeader("Content-length", (int)rs.getBlob("ATTACH_FILE").length());
InputStream is = rs.getBinaryStream("ATTACH_FILE");
byte[] buf = new byte[3000];
int read = 0;
while ((read = is.read(buf)) > 0)
{
// fos.write(buf, 0, read);
outs.write(buf, 0, read);
}
// fos.close();
is.close();
outs.flush();
// outs.close();
}
星期四, 十月 16, 2008
SQLite自定义函数简介
SQLite最大的特色之一就是可以用户定义函数。用户自定义函数可以像系统内置函数一样可以在注册之后像系统内置函数一样在SQL语句中使用。用户使用自定义函数类似存储过程,方便用户对常见功能的调用,也加快了执行速度。用户自定义函数整体上可以分为两种:简单函数和聚集函数。
简单函数(simple function)
简单函数用在任何表达式中,常见的有max(x,y..), min(x,y..), random(*), last_insert_rowid(), length(x),lower(x), upper(x), round(x,y), round(*), substr(x,y,z), typeof(x)
聚集函数(aggregate function)
聚集函数经常用在select语句中,常见的有avg(x),count(x), count(*), max(x), min(x), sum(x), total(x)
有些函数既是简单函数,又是聚集函数。比如只有一个参数的min()是一个聚集函数,而有多个参数的min()是一个简单函数。
SQLITE比较好的书有两本:
一个是:O'Reilly出版的 Inside SQLite
一个是:Apress.The.Definitive.Guide.to.SQLite.May.2006
星期一, 十月 13, 2008
如何立即刷新Java Swing Jcomponent组件?
如果想立即刷新JTextArea的内容去,需要调用一下语句。
JTextArea sql2= new JTextArea(5,10);
Point pt=sql2.getLocation();
Dimension ds=sql2.getSize();
sql2.paintImmediately((int)pt.getX(),(int)pt.getY(), (int)ds.getWidth(),(int)ds.getHeight());
这个工作的非常好。
星期四, 十月 09, 2008
得到当前运行class的物理位置
URL classFileDir =new yourClassName().getClass().getResource(".");
print结果为:file:....的URL
星期三, 十月 08, 2008
Windows XP SP2手工修改屏幕分辨率
Intel(R) Extreme Graphics 除了在注册表:
HKEY_CURRENT_CONFIG\System\CurrentControlSet\Control\VIDEO有引用,
本身在:
[HKEY_CURRENT_CONFIG\System\CurrentControlSet\SERVICES\IALM]也有设置,必须删除这个设置
再启动机器后,才能正常进入。
[HKEY_CURRENT_CONFIG\System\CurrentControlSet\SERVICES\IALM\DEVICE0]
[HKEY_CURRENT_CONFIG\System\CurrentControlSet\SERVICES\IALM\DEVICE0\Mon80861100]
这两个注册表项目要删除掉